[英]App not resuming when clicking notification
I have integrated FCM into my app using react-native-firebase我已经使用react-native-firebase将 FCM 集成到我的应用程序中
When I background my app and receive a Push Notification, I want my app to resume from the background state.当我后台我的应用程序并收到推送通知时,我希望我的应用程序从后台 state 恢复。
It appears the onCreate()
function from MainActivity
is being called because I can see my SplashScreen.似乎正在调用MainActivity
的onCreate()
function,因为我可以看到我的 SplashScreen。
Here's my AndroidManifest.xml这是我的 AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="myapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/notification_icon" />
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<!-- Background Messages (Optional) -->
<service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />
</application>
</manifest>
Set launchMode
in your activity to avoid notifications from creating a new Activity
instance.在您的 Activity 中设置launchMode
以避免通知创建新的Activity
实例。
Set launchMode
of your SplashScreen
to singleInstance
.将SplashScreen
的launchMode
设置为singleInstance
。
Refer: https://developer.android.com/guide/topics/manifest/activity-element.html#lmode参考: https://developer.android.com/guide/topics/manifest/activity-element.html#lmode
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.