Commit 73a0cc70 authored by Libin Lu's avatar Libin Lu

bump version

parent fb96bb2d
...@@ -16,8 +16,8 @@ https://github.com/oney/TestGcm ...@@ -16,8 +16,8 @@ https://github.com/oney/TestGcm
- In `android/build.gradle` - In `android/build.gradle`
```gradle ```gradle
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.0.0' classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.google.gms:google-services:3.0.0' // <- Add this line classpath 'com.google.gms:google-services:3.0.0' // <- Add this line
``` ```
- In `android/app/build.gradle` - In `android/app/build.gradle`
...@@ -31,21 +31,21 @@ apply plugin: 'com.google.gms.google-services' // <- Add this line ...@@ -31,21 +31,21 @@ apply plugin: 'com.google.gms.google-services' // <- Add this line
``` ```
<application <application
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
... ...
<service android:name="com.evollu.react.fcm.MessagingService"> <service android:name="com.evollu.react.fcm.MessagingService">
<intent-filter> <intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/> <action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter> </intent-filter>
</service> </service>
<service android:name="com.evollu.react.fcm.InstanceIdService" android:exported="false"> <service android:name="com.evollu.react.fcm.InstanceIdService" android:exported="false">
<intent-filter> <intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/> <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter> </intent-filter>
</service> </service>
... ...
``` ```
### IOS Configuration ### IOS Configuration
...@@ -55,22 +55,28 @@ install pod 'Firebase/Messaging' ...@@ -55,22 +55,28 @@ install pod 'Firebase/Messaging'
in AppDelegate.m add in AppDelegate.m add
``` ```
#import "FCMModule.h" #import "FCMModule.h"
``` ...
``` - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
....
[FIRApp configure]; <-- add this line
}
//add this
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification { - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification {
[[NSNotificationCenter defaultCenter] postNotificationName: FCMNotificationReceived [[NSNotificationCenter defaultCenter] postNotificationName: FCMNotificationReceived
object:self object:self
userInfo:notification]; userInfo:notification];
} }
//add this
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))handler { - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))handler {
[[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived
object:self object:self
userInfo:notification]; userInfo:notification];
handler(UIBackgroundFetchResultNoData); handler(UIBackgroundFetchResultNoData);
} }
``` ```
...@@ -85,30 +91,31 @@ In [firebase console](https://console.firebase.google.com/), you can get `google ...@@ -85,30 +91,31 @@ In [firebase console](https://console.firebase.google.com/), you can get `google
var FCM = require('react-native-fcm'); var FCM = require('react-native-fcm');
componentWillMount() { componentWillMount() {
FCM.requestPermissions(); FCM.requestPermissions();
FCM.getFCMToken().then(token => { FCM.getFCMToken().then(token => {
//store fcm token in your server //store fcm token in your server
}); });
this.fcmNotifLsnr = DeviceEventEmitter.addListener('FCMNotificationReceived', (notif) => { this.fcmNotifLsnr = DeviceEventEmitter.addListener('FCMNotificationReceived', (notif) => {
//there are two parts of notif. notif.notification contains the notification payload, notif.data contains data payload //there are two parts of notif. notif.notification contains the notification payload, notif.data contains data payload
}); });
this.fcmTokenLsnr = DeviceEventEmitter.addListener('FCMTokenRefreshed', (token) => { this.fcmTokenLsnr = DeviceEventEmitter.addListener('FCMTokenRefreshed', (token) => {
//fcm token may not be available on first load, catch it here //fcm token may not be available on first load, catch it here
}); });
} }
componentWillUnmount() { componentWillUnmount() {
//prevent leak //prevent leak
this.fcmNotifLsnr.remove(); this.fcmNotifLsnr.remove();
this.fcmTokenLsnr.remove(); this.fcmTokenLsnr.remove();
} }
} }
``` ```
## Q & A ## Q & A
### Why my android build is co ### My android build is failing
### Why I don't get data notification when app is killed? Try update your SDK and google play service
### I can't get data notification when app is killed?
If you send notification with payload only, you can only get the data message when app is in foreground or background. Killed app can't show notification If you send notification with payload only, you can only get the data message when app is in foreground or background. Killed app can't show notification
### Why I don't get data notification when I'm sending hybrid notification when app is in background? ### Why I don't get data notification when I'm sending hybrid notification when app is in background?
I want to figure it out too. Looks like that is how GCM/FCM works. I'm sending 2 notification separately for now. Let me know if you find a better solution I want to figure it out too. Looks like that is how GCM/FCM works. I'm sending 2 notification separately for now. Let me know if you find a better solution
......
{ {
"name": "react-native-fcm", "name": "react-native-fcm",
"version": "1.0.0", "version": "1.0.1",
"description": "React Native component for FCM for IOS and Android", "description": "React Native component for FCM for IOS and Android",
"repository": { "repository": {
"type": "git", "type": "git",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment