evollu / react-native-fcm

react native module for firebase cloud messaging and local notification
MIT License
1.73k stars 682 forks source link

[IOS] Don't Receive Notification after one night #574

Open thoth-nexlesoft opened 7 years ago

thoth-nexlesoft commented 7 years ago

I have configured my project, app have been received notification foreground, background and kill app states (react-native-fcm@9.1.0). But app wasn't been received notification on yesterday. When I upgrade react-native-fcm@9.3.0 app isn't been receive notification too. When I downgrade react-native-fcm@6.2.3 app only is been received notification foreground state. I don't understand what's happen.

Can you help me? @evollu

"react": "16.0.0-alpha.12", "react-native": "^0.48.1"

evollu commented 7 years ago

if there is no code change, something is happening with Firebase?

thoth-nexlesoft commented 7 years ago

This is payload when server push notification:

const object = {
    "id": "4",
    "title": "Test Title 182",
    "content": "Test content",
    "type": "info",
    "date": "2017-08-22",
    "shop": "Pizza",
    "user_id": "8",
  }
  const payload = {
    data: object,
    notification: {
      "sound": "default",
      "body" : object.content,
      "title" : object.title,
      "icon": "ic_notification"
    }
  }

And this data app has been received notification:

{ user_id: '8',
  collapse_key: 'com.biits.managedev',
  date: '2017-08-22',
  from: '123456',
  notification: 
   { e: '1',
     sound2: 'default',
     sound: 'default',
     icon: 'ic_notification',
     title: 'Test Title 182',
     body: 'Test content' },
  type: 'info',
  content: 'Test content',
  title: 'Test Title 182',
  id: '4',
  shop: 'Pizza',
  finish: [Function: finish] }

I don't know why app has been received notification with properties e: '1', sound2: 'default',

@evollu

evollu commented 7 years ago

e is created by fcm, not sure about sound2. you said you can't receive notification, so what is data you received? foreground?

what is you OS?

But app wasn't been received notification on yesterday banner not showing up or callback not called

thoth-nexlesoft commented 7 years ago

The notification above, app has been received when I downgrade react-native-fcm@6.2.3 app only is been received notification foreground state. @evollu

evollu commented 7 years ago
  1. what is your OS?
  2. But app wasn't been received notification on yesterday Is banner not showing up or callback not called?
thoth-nexlesoft commented 7 years ago
  1. I have test on IOS version 10.3.3 and 11.0.0
  2. I don't see log when server push notification (callback not called).

But when I I downgrade react-native-fcm@6.2.3 and 'Firebase/Messaging', '3.17.0' when app has been received notification with issue duplicate notification. @evollu

evollu commented 7 years ago

FCM < 4 has direct connection socket open automatically so you can receive notification foreground. The problem should be notification certificate setup. Can you reproduce with example project?

thoth-nexlesoft commented 7 years ago

Can you sure the example project is receive notification at foreground, background and kill app at the moment? @evollu

evollu commented 7 years ago

yep it works for me

thoth-nexlesoft commented 7 years ago

I have created again certificate and export .p12 file, I have imported on firebase. But app isn't been received notification. I tried push notification token type with firebase server.

evollu commented 7 years ago

try APNs Auth Key?

thoth-nexlesoft commented 7 years ago

I have try APNs Auth Key but app isn't been received notification too.

evollu commented 7 years ago

if you are using iOS11, try latest repo. otherwise, try the native example from Firebase (quickstart-ios) and see if you can receive notification.

thoth-nexlesoft commented 7 years ago

I have received notification with example native code project https://github.com/firebase/quickstart-ios/tree/master/messaging

evollu commented 7 years ago
  1. have you tried the latest repo with iOS11?
  2. if you don't see any notification, does appdelegate.m's callbacks get triggered?
  3. if you send global notification through firebase console, does problematic device get notification?
  4. can you reproduce it with example project?
thoth-nexlesoft commented 7 years ago

I try with IOS 10.3.3 anh IOS 11

thoth-nexlesoft commented 7 years ago

I don't receive notification with example fcm project too when I send global notification through firebase console.

And I don't see log receive notification from the methods

+ (void)didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull RCTRemoteNotificationCallback)completionHandler {
    NSMutableDictionary* data = [[NSMutableDictionary alloc] initWithDictionary: userInfo];
    NSLog(@"didReceiveRemoteNotification data: %@", data);
    [data setValue:@"remote_notification" forKey:@"_notificationType"];
    [data setValue:@(RCTSharedApplication().applicationState == UIApplicationStateInactive) forKey:@"opened_from_tray"];
    [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:@{@"data": data, @"completionHandler": completionHandler}];
}

+ (void)didReceiveLocalNotification:(UILocalNotification *)notification {
    NSMutableDictionary* data = [[NSMutableDictionary alloc] initWithDictionary: notification.userInfo];
    NSLog(@"didReceiveLocalNotification data: %@", data);
    [data setValue:@"local_notification" forKey:@"_notificationType"];
    [data setValue:@(RCTSharedApplication().applicationState == UIApplicationStateInactive) forKey:@"opened_from_tray"];
    [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:@{@"data": data}];
}

+ (void)didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(nonnull RCTNotificationResponseCallback)completionHandler
{
    NSMutableDictionary* data = [[NSMutableDictionary alloc] initWithDictionary: response.notification.request.content.userInfo];
    NSLog(@"didReceiveNotificationResponse data: %@", data);
    [data setValue:@"notification_response" forKey:@"_notificationType"];
    [data setValue:@YES forKey:@"opened_from_tray"];
    if (response.actionIdentifier) {
        [data setValue:response.actionIdentifier forKey:@"_actionIdentifier"];
    }
    [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:@{@"data": data, @"completionHandler": completionHandler}];
}

+ (void)willPresentNotification:(UNNotification *)notification withCompletionHandler:(nonnull RCTWillPresentNotificationCallback)completionHandler
{
    NSMutableDictionary* data = [[NSMutableDictionary alloc] initWithDictionary: notification.request.content.userInfo];
    NSLog(@"willPresentNotification data: %@", data);
    [data setValue:@"will_present_notification" forKey:@"_notificationType"];
    [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:@{@"data": data, @"completionHandler": completionHandler}];
}

Please check again example project. @evollu

evollu commented 7 years ago

try the latest example in master branch and send notification through the app by clicking the button. You will need to replace the FirebaseConstant.js and GoogleService-Info.plist file with your own match ones

mine works fine img_9428

thoth-nexlesoft commented 7 years ago

I have received notification with example project, but I don't receive notification with my project. I have upgraded react-native-fcm latest, and run again pod install.

I can get token but Appdelegate.m don't callback get triggered?

Have you configured more example project?

evollu commented 7 years ago

there is a change in AppDelegate.m for xcode 8/9 compatibility. Have you changed it? it is in readme

evollu commented 7 years ago

check this https://github.com/firebase/quickstart-ios/issues/327#issuecomment-331782299

thoth-nexlesoft commented 7 years ago

Thanks @evollu , I have downgrade pod 'FirebaseInstanceID', '2.0.0'. App has been received notification. But now app been received duplicate notifications, when server send one notification.

evollu commented 7 years ago

you mean the callback called multiple times? it is expected

thoth-nexlesoft commented 7 years ago

It is bug. I'm expect show 1 notification when server send notification 1 time. But now app been received duplicate notifications, when server send one notification.

evollu commented 7 years ago

are you seeing multiple banners?

thoth-nexlesoft commented 7 years ago

[Android] Yes, I'm only see 1 log line received notification, but notification bar show multiple banners?

evollu commented 7 years ago

are you scheduling local notification anywhere? debug this and see how many times it is called https://github.com/evollu/react-native-fcm/blob/master/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java#L46

thoth-nexlesoft commented 7 years ago

I don't use to schedule local notification. I use to push notification with topic.