Open kienlv58 opened 7 years ago
this is a data i send in postman: { "to":"emlkHdBusBA:APA91bEpVRdOpBZOWsk_OiUPopWNrUzpeAXVhvmPYBrM1OtdYPReQ1ZkiukDZta4L1LwURrqNiqdovtRjqIOPOzGtwloElXKIEV3DaylAn8HsvAW4-ebiDdK5XxpdQ9YAhWy6sxAZc-J", "data": { "type":"MEASURE_CHANGE", "custom_notification": { "body": "test body", "title": "test title", "color":"#00ACD4", "priority":"high", "icon":"ic_notif", "group": "GROUP", "id": "id", "show_in_foreground": true } } }
iOS will not receive data notification if user swipe them away from tasks. System limit
i testing is android. can you fix it?
did you add permissions in manifest? also what is you testing device?
please read and answer these questions when you open issues
Before openning an issue
Reproduce it with the example project in this repo. If you can't receive iOS notification, make sure you can receive notification using quickstart-ios project provided by Firebase team When openning an issue, please include following information for better support
What version of RN and react-native-fcm are you running? What device are you using? (e.g iOS9 emulator, Android 6 device)? Is your app running in foreground, background or not running?
i using react native 0.48 and i using android device 5.0. i config look like you guide in readme but when i kill app on android, i still not receive notification. i try find something difference between my code and your code demo but not difference
Same issue here any solution ? react-native 0.49.0 react-native-fcm 10.0.0 ios 11
@kienlv58 are you testing with android emulator? does demo project work? can you show the manifest file?
i have same issue.
react-native: 0.46.0 react-native-fcm : 10.0.3 target os : Android
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="co.xxx.xx"
android:versionCode="3000007"
android:versionName="3.0.7">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<permission android:name="com.maps.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
<uses-permission android:name="com.maps.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- react-native-background-geolocation licence -->
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="23" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:launchMode="singleTop"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme">
<service android:name="com.evollu.react.fcm.MessagingService" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name="com.evollu.react.fcm.InstanceIdService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<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>
<intent-filter>
<action android:name="fcm.ACTION.HELLO" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_launcher"/>
<receiver android:name="com.evollu.react.fcm.FIRLocalMessagingPublisher"/>
<receiver android:enabled="true" android:exported="true" android:name="com.evollu.react.fcm.FIRSystemBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>
@evollu, how should be the json to send for an iOS notification to run in foreground without been shown, something like "show_in_foreground": false?
This json works fine for a push notification in iOS:
{
"to": "FCM_TOKEN_ID-xxxxxxxxxxxxxxx",
"notification":{
"title" : "traffic Title",
"body" : "Traffic Body",
"content_available" : true,
"priority" : "low",
"id": 4,
"sound": ""
}
}
But I need to send push notifications that doesn't been shown, it is not working for me, there isn't arriving nothing with this json:
{
"to": "FCM_TOKEN_ID-xxxxxxxxxxxxxxx",
"data": {
"type":"MEASURE_CHANGE",
"custom_notification": {
"body": "test body",
"title": "test title",
"color":"#00ACD4",
"priority":"high",
"icon":"ic_notif",
"group": "GROUP",
"id": "id",
"show_in_foreground": false
}
}
}
Also, I'm extracting the data with the event listener, but doesn't arrive nothing with a custom_notification in iOS:
this.notificationListener = FCM.on(FCMEvent.Notification, async (notif) => {
console.log(notif.gcm.notification);
}
PD:
if(Platform.OS ==='ios'){
//optional
//iOS requires developers to call completionHandler to end notification process. If you do not call it your background remote notifications could be throttled, to read more about it see the above documentation link.
//This library handles it for you automatically with default behavior (for remote notification, finish with NoData; for WillPresent, finish depend on "show_in_foreground"). However if you want to return different result, follow the following code to override
//notif._notificationType is available for iOS platfrom
switch(notif._notificationType){
case NotificationType.Remote:
notif.finish(RemoteNotificationResult.NewData) //other types available: RemoteNotificationResult.NewData, RemoteNotificationResult.ResultFailed
break;
case NotificationType.NotificationResponse:
notif.finish();
break;
case NotificationType.WillPresent:
const presenterType = (notif.show_in_foreground === 'false') ? WillPresentNotificationResult.None : WillPresentNotificationResult.All;
notif.finish(presenterType) //other types available: WillPresentNotificationResult.None
break;
}
}
This approach works as I expect, there was been forced to be shown always with notif.finish(WillPresentNotificationResult.All)
I have use the sample document but the problem if I try to send notification from Firebase Notificiation, I didnt receive any notification background when my app is close. I tried in development debug or release but still no notification alert in my iOS device. the only thing I receive a message when I open my app and on this part
this.notificationListener = FCM.on(FCMEvent.Notification, async (notif) => {
// optional, do some component related stuff
});
it just print the notification I sent from Firebase Notification.
Need advice on this issue, thanks
try combine this with @ecarrera 's answer
{
"to": "FCM_TOKEN_ID-xxxxxxxxxxxxxxx",
"notification":{
"title" : "traffic Title",
"body" : "Traffic Body",
"content_available" : true,
"priority" : "low",
"id": 4,
"sound": ""
},
"data": {"show_in_foreground" : false}
}
if(Platform.OS ==='ANDROID') ..... how to do this for android? can anyone help me to come out this
@MbF-Sathya lowercase android
@evollu I'm sending notification from C# code
{
to: "fcm_token",
notification: {
body: "your order is okay",
title: "Brg - Your order"
},
data:{
body: "your order is okay",
title: "Brg - Your order",
type="newentry"
}
}
I'm receiving notification on ios. I'm performing some actions in FCM.on(FCMEvent.Notification, notif => { method.
this.notificationListener = FCM.on(FCMEvent.Notification, async (notif) => { is only called when iOS app is in foreground not in background. When opening app clicked from notification this is never called.
It's really urgent awaiting for your reply. Thank You.
try add content_available: true
@sfm2222
@evollu it is not working. I tried to place it in notification or in data.
{ to: "fcm_token", notification: { body: "your order is okay", title: "Brg - Your order", //content_available: true }, data:{ body: "your order is okay", title: "Brg - Your order", type="newentry", //content_available: true }, content_available: true }
type="newentry"
or `type: "newentry"?
I've tried even removing the type, it's just another data I'm trying to pass. It's not helping out even though. In c# code I'm using equal sign.
My current method looks like var postdata = new { to = fcmid, notification = new { title="new", body= "new body", sound="default", priority="high" }, data = new { title = "new title", body= "new body", sound= "default" }, content_available=true }
does the notification banner show up when you are in background?
yes I get it in top notification banner in background but once I click the notification FCM.on(FCMEvent.Notification, notif => { method. event don't get hit. But if application is open this method get called and even it shows data received from the notification.
Even if we exit from the application and it stills give us notification, everything works fine except when application is closed that is in Background, clicking on notification don't take us to the FCM.on event.
try add breakpoint in xcode at
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{
[RNFIRMessaging willPresentNotification:notification withCompletionHandler:completionHandler];
}
see if this method gets called correctly.
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{
[RNFIRMessaging willPresentNotification:notification withCompletionHandler:completionHandler];
}
I checked. No it is not called in background.
This method is only called when application is in foreground not when application is closed i.e: in background.
then it has to do with ios config. Have you add capability for background push?
Yes we have added both remote notification capability and push notification. What else we can check in the configuration? Everything is already set up according to your given guidelines.
i have no clue now. could the system setting disabled the background capability? Have you tried to delete the app and reinstall?
What is meant by system setting here, if you are asking about device system settings we have checked it on multiple iOS devices, also installed the app numerous times.
Have you tried doing the same and it works? I'll try your example project and recreate the same scenario and then let you know. I really appreciate your help.
yeah try the example project
I got my push notification token? but i didnt get push notification. Which code is to receive push notification?
@evollu do react-native-firebase have solved this issue to handle iOS remote notification when app is not running? I need that feature urgently...
@ecarrera can you check with them? They said it was in progress. or you can try placing your callback outside of component lifecycle and see it works for you
there is a known issue with Firebase SDK with iOS 11 https://github.com/firebase/quickstart-ios/issues/327#issuecomment-331782299 fix is
pod 'FirebaseInstanceID', "2.0.0"
Before openning an issue
When openning an issue, please include following information for better support