Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

onNotification Not working when app is killed at foreground #1795

Closed
selvaTecky opened this issue Dec 29, 2020 · 9 comments
Closed

onNotification Not working when app is killed at foreground #1795

selvaTecky opened this issue Dec 29, 2020 · 9 comments
Labels

Comments

@selvaTecky
Copy link

Hi,

The package is really useful for creating push notifications. I have few doubts and questions hope you'll help me on this.

  1. onNotifications are executing in foreground without an issue but, if I send push notifications when the app is in killed state that time it is not even executing but onRegister executing without fail. May I know why its functioning like this?

  2. Is it required to pass "data" object in remote push notification? if I don't have any options to pass data what will happen?

@Dallas62
Copy link
Collaborator

Hi @selvaTecky,

Since this library is not responsible of the Firebase protocol, you can refer to this documentation:

https://firebase.google.com/docs/cloud-messaging/concept-options

Basically:
In killed state, onNotification is called only if it's a data-only notification.
Or if the user press the notification.

Regards,

@selvaTecky
Copy link
Author

selvaTecky commented Dec 30, 2020

Hi @Dallas62 ,

I am sending payload without data only. But while clicking on notifications, onNotification is not getting executed. I have debugged, onRegister only getting executed there I won't get notification payload. Can you give some idea on this?

ReactNative: 59.8
react-native-push-notifications: 3.0.1

@Dallas62
Copy link
Collaborator

Hi,

Your library is too old, but take a look in issues for:

  • SplashScreen

Or move .configure() outside any component.

Regards,

@selvaTecky
Copy link
Author

Hi @Dallas62 ,

As per your advice I have updated the package. Currently I am using react-native-push-notification: ^3.3.0. Now onNotification is getting executed but the push notification is not popping up in notification trey. do you have any idea?
I have shared my payload, kindly take a look.

{
"foreground": true,
"userInteraction": false,
"id": "xxxxxx",
"data": {
"name": "Testing Messgae",
"Title": "Testing",
"pr": "",
}
}

@Dallas62
Copy link
Collaborator

Dallas62 commented Jan 4, 2021

Hi @selvaTecky

As mentioned before, please refer to:
https://firebase.google.com/docs/cloud-messaging/concept-options#notifications

Regards,

@selvaTecky
Copy link
Author

Hi @Dallas62 ,

I am totally confused thats why I am asking your support on this. I am using third party cloud messaging. from that I will get payload list that only I can't able to change that payload format. Earlier in 3.0.1 I am getting notification popup but now the notification pop up is not coming. I have shared my Push notification configuration in manifest file. Am I missed anything.

RN Version: 59.9
Push notification Current Version: 3.3.0

  <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_name"
          android:value="test-channel"/>
  <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_description"
              android:value="test-channel-desc"/>
              
  <meta-data  android:name="com.dieam.reactnativepushnotification.notification_foreground"
                android:value="false"/>
  <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
              android:resource="@android:color/white"/>

  <!-- <receiver
      android:name="com.google.android.gms.gcm.GcmReceiver"
      android:exported="true"
      android:permission="com.google.android.c2dm.permission.SEND" >
      <intent-filter>
          <action android:name="com.google.android.c2dm.intent.RECEIVE" />
          <category android:name="xxx.yyyy.zzzzz" />
      </intent-filter>
  </receiver> -->






  <!--<service-->
      <!--android:name="com.clevertap.android.sdk.GcmMessageListenerService"-->
      <!--android:exported="false" >-->
      <!--<intent-filter>-->
          <!--<action android:name="com.google.android.c2dm.intent.RECEIVE" />-->
      <!--</intent-filter>-->
  <!--</service>--> 
  <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" />
  <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
  <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
      <intent-filter>
          <action android:name="android.intent.action.BOOT_COMPLETED" />
          <action android:name="android.intent.action.QUICKBOOT_POWERON" />
          <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
      </intent-filter>
  </receiver>

  <!-- <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/> -->


      <!-- <service
          android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
          android:exported="false" >
          <intent-filter>
              <action android:name="com.google.android.c2dm.intent.RECEIVE" />
          </intent-filter>
      </service> -->

      <!-- <service 
        android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerServiceGcm" 
        android:exported="false"> 
          <intent-filter> 
            <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 
          </intent-filter> 
      </service> -->

      <service
        android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

@Dallas62
Copy link
Collaborator

Dallas62 commented Jan 4, 2021

You can take a look to this issue: #1452

@github-actions
Copy link

github-actions bot commented Jan 5, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

@shafqatbarireporteq
Copy link

any Solution? Please share

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants