android - 应用程序被杀死时Android中的FCM通知
问题描述
我正在尝试使用此链接将推送通知(FCM)发送到我的 android 应用程序。当应用程序在后台时一切正常,但是一旦我终止应用程序,我就不会收到任何通知。我使用 Lenovo Tab 和 Android 7.1 OS.I还尝试签署应用程序并安装为 APK。下面是我的 gradle 文件和 logcat 输出:-
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name"
android:value="YOUR NOTIFICATION CHANNEL NAME"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description"
android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/>
<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="com.liappmanager" />
</intent-filter>
</receiver>
<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" />
</intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
<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>
<service android:name=".MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name=".FirebaseIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
</application>
logcat 输出:-
03-02 12:00:15.673 1489 1536 W BroadcastQueue: Unable to launch app
com.liappmanager/10279 for broadcast Intent {
act=com.google.android.c2dm.intent.RECEIVE flg=0x10000010
pkg=com.liappmanager (has extras) }: process is not granted
03-02 12:00:15.676 2369 2369 W GCM : broadcast intent callback:
result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE
flg=0x10000000 pkg=com.liappmanager (has extras) }
正如您从 logcat 中看到的那样,我了解未授予权限,但我在 gradle 文件中添加了权限。我仍然缺少有关权限的内容。
[已解决]:如果您使用联想,我终于解决了只需转到设置->电池优化->所有应用程序->{您的应用程序}->不要优化(检查它)就是这样(重新启动设备),将解决问题以供进一步参考检查 此。
解决方案
推荐阅读
- python-3.x - 我需要在发票模型中显示合并的日期字段,特别是在发票模型的 date_invoice 字段中
- c++ - 如何在VS项目中静态链接没有dll文件的cpprest?
- java - Python 调用的服务执行程序问题
- css - 根据数据库中的值更改 css
- gremlin - Gremlin.createClient 不是 3.3.4 版本中的函数
- javascript - 从文件上传 html 的 textarea 中删除模糊 | CSS | javascript
- javascript - 如何让机器人找到频道所有者/与作者的 ID 进行比较
- asp.net-core - 当前上下文中不存在 AddAzureAD(与 Azure AD 集成的 Asp.net 核心 Web 应用)
- java - 无法打开java导出的jar文件
- javascript - 将数据传递给另一个组件 OnClick