Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 28460

Push notification not receiving some Android 9 background

$
0
0

I am trying to catch the problem with Expo React Native SDK 34 in push notification service. In most android 9 devices i have a couple of problems, but the weirdest is that in push notification is receiving in foreground but not in background and obviously that is a huge problem because is the way we have to let users knows something to trigger the open app.

I have already tried installing Sentry (error catcher) to see if there is a problem but nothing happended.

I also tried to put a button with label to see the permission of the push, in this case the permission said "granted" and that seems obvious because we receive the push in foreground, but also check the permission display in the android config and all seems good.... super weird.

Another fact is that in some cases, those phones neither receive instagram push notification... so maybe is a react native issue?

Then when i saw the Google Play Console errors logs the output for some devices with the android 9 was =>

Android output problem:


java.lang.RuntimeException: 
  at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4000)
  at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:4032)
  at android.app.servertransaction.ResumeActivityItem.execute (ResumeActivityItem.java:51)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:145)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:70)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1976)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:193)
  at android.app.ActivityThread.main (ActivityThread.java:6912)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:860)
Caused by: java.lang.IllegalStateException: 
  at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1592)
  at android.app.ContextImpl.startService (ContextImpl.java:1547)
  at android.content.ContextWrapper.startService (ContextWrapper.java:664)
  at host.exp.exponent.experience.BaseExperienceActivity.registerForNotifications (BaseExperienceActivity.java:258)
  at host.exp.exponent.experience.ExperienceActivity.onResume (ExperienceActivity.java:256)
  at android.app.Instrumentation.callActivityOnResume (Instrumentation.java:1434)
  at android.app.Activity.performResume (Activity.java:7300)
  at android.app.ActivityThread.performResumeActivity (ActivityThread.java:3992)
  at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:4032)
  at android.app.servertransaction.ResumeActivityItem.execute (ResumeActivityItem.java:51)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:145)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:70)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1976)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:193)
  at android.app.ActivityThread.main (ActivityThread.java:6912)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:860)

My handler of notification is with expo-notifications. I also tried with channel id in android because i know a couple of changes were made and channelId is the key, but did not work either.

_handleNotification = (notification) => {
    //TODO exec un post para guardar el js notification. SI android 9 + android version + background status or foreground.
    if (Platform.OS === 'android') {
      Notifications.createChannelAndroidAsync('chat-messages', {
        name: 'Chat messages',
        sound: true,
        vibrate: true,
        priority: 'max',
        vibrate: [0, 250, 250, 250]
      });
    }
    this.setState({ pushNotification: notification }, () => {
      if (!this.state.pushNotification.data.show_message || this.state.pushNotification.data.refresh) {
        this.getNews();
      } else if (this.state.pushNotification.data.show_message) {
        Alert.alert(notification.data.titulo.toString(), notification.data.cuerpo.toString());
      } else {
        console.log('no hizo nadachr');
      }
    });

  };

Viewing all articles
Browse latest Browse all 28460

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>