Commit eb8f865a authored by Libin Lu's avatar Libin Lu

pass token instead of object in refresh callback

parent fd8f4a4c
......@@ -89,15 +89,13 @@ in AppDelegate.m add
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
....
[FIRApp configure]; <-- add this line
[FIRApp configure]; <-- add this line
}
//add this method
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification {
[[NSNotificationCenter defaultCenter] postNotificationName: FCMNotificationReceived
object:self
userInfo:notification];
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))handler {
[[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:notification];
handler(UIBackgroundFetchResultNoData);
}
```
......@@ -120,8 +118,8 @@ In [firebase console](https://console.firebase.google.com/), you can get `google
this.notificationUnsubscribe = FCM.on('notification', (notif) => {
// there are two parts of notif. notif.notification contains the notification payload, notif.data contains data payload
});
this.refreshUnsubscribe = FCM.on('refresh', (data) => {
console.log(data.token)
this.refreshUnsubscribe = FCM.on('refreshToken', (token) => {
console.log(token)
// fcm token may not be available on first load, catch it here
});
}
......
......@@ -96,10 +96,7 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li
if (getReactApplicationContext().hasActiveCatalystInstance()) {
String token = intent.getStringExtra("token");
WritableMap params = Arguments.createMap();
params.putString("token", token);
sendEvent("FCMTokenRefreshed", params);
sendEvent("FCMTokenRefreshed", token);
abortBroadcast();
}
}
......
......@@ -86,9 +86,7 @@ RCT_REMAP_METHOD(getFCMToken,
- (void) onTokenRefresh
{
NSDictionary *info = @{@"token":[[FIRInstanceID instanceID] token]};
[_bridge.eventDispatcher sendDeviceEventWithName:@"FCMTokenRefreshed"
body:info];
[_bridge.eventDispatcher sendDeviceEventWithName:@"FCMTokenRefreshed" body:[[FIRInstanceID instanceID] token]];
}
RCT_EXPORT_METHOD(requestPermissions)
......
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