我正在尝试在推送通知服务中解决Expo React Native SDK 34的问题。在大多数android 9设备中,我有几个问题,但最奇怪的是,推送通知是在前台接收的,而不是在后台接收的,显然这是一个很大的问题,因为这是我们必须让用户知道触发打开的方式应用程式。
我已经尝试安装Sentry(错误捕获器)以查看是否有问题,但是什么也没发生。
我还尝试放置带有标签的按钮以查看推送的权限,在这种情况下,权限说“已授予”,这似乎很明显,因为我们收到了前台的推送,而且还检查了android中的权限显示配置,一切似乎都很好。...超级奇怪。
另一个事实是,在某些情况下,这些手机均未收到instagram推送通知...所以这可能是一个本机反应?
然后,当我看到Google Play控制台错误时,使用android 9记录了某些设备的输出==
Android输出问题:
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)
我的通知处理程序带有expo-notifications。我也尝试在android中使用通道ID,因为我知道已进行了一些更改,而channelId是关键,但也没有用。
_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');
}
});
};