StartActivity Not Working Inside OnMessageReceived In Fcm
Solution 1:
This is because SYSTEM_ALERT_WINDOW
permission is not granted by the user. In case someone needs to know how to grant the SYSTEM_ALERT_WINDOW
persmission, here is the link
SYSTEM_ALERT_WINDOW - How to get this permission automatically on Android 6.0 and targetSdkVersion 23
Solution 2:
There are two types of messages data messages and notification messages. Data messages are handled here in onMessageReceived whether the app is in the foreground or background. Data messages are the type traditionally used with GCM. Notification messages are only received here in onMessageReceived when the app is in the foreground. When the app is in the background an automatically generated notification is displayed. When the user taps on the notification they are returned to the app. Messages containing both notification and data payloads are treated as notification messages. The Firebase console always sends notification messages.
Example code :- You need to specify click_action in your notification payload like this
$noti = array
(
'icon' => 'new',
'title' => 'title',
'body' => 'new msg',
'click_action' => 'open_NewOrderActivity'
);
Now in manifest
file do this in your NewOrderActivity
activity tag
<activity
android:name=".NewOrderActivity">
<intent-filter>
<action android:name="open_NewOrderActivity" /> // should be same as in click action
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
Post a Comment for "StartActivity Not Working Inside OnMessageReceived In Fcm"