Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ios data message help?? #349

Open
tsaritepe opened this issue Jul 5, 2017 · 3 comments
Open

ios data message help?? #349

tsaritepe opened this issue Jul 5, 2017 · 3 comments

Comments

@tsaritepe
Copy link

tsaritepe commented Jul 5, 2017

I cant receive data only message from ios. It is working with notification title and body, but it is not when i just send data. The point is i want to send data only without notifying user for app to sync.

By the way it is working on android. Anyone have an idea?

{ "data": {
"action": "seen"
},
"to" : "d9iD6nCK61w:APA91bGxcCR5w.....f"
}

@tsaritepe tsaritepe changed the title ios data message problem ios data message help?? Jul 5, 2017
@fechanique
Copy link
Owner

Follow the instructions to send a message via API, also try using the free testing server.

@lostin70s
Copy link

Hi, I have the same issues, the notification will not work if there is no "notification :{}" object in the message for ios > 9 for example if you want data only notification (silent notification)

If ios > 9, the plugin let the notification centre methods to handle the notification but this latter is not activated in case of data only message.

You can fix it by adding code from line 199 of AppDelegate+FCMplugin.m file

  • (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
    fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
    {

    // Short-circuit when actually running iOS 10+, let notification centre methods handle the notification.
    if (NSFoundationVersionNumber >= NSFoundationVersionNumber_iOS_9_x_Max) {

      // check if message is a silent message
      NSError *error2;
      NSDictionary *userInfoMutable2 = [userInfo mutableCopy];
      NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:userInfoMutable2
                                                          options:0
                                                            error:&error2];
      
      NSString* JSONString = [[NSString alloc] initWithBytes:[jsonData2 bytes] length:[jsonData2 length] encoding:NSUTF8StringEncoding];
      
      if ([JSONString rangeOfString:@"FCM_PLUGIN_ACTIVITY"].location != NSNotFound)
          return;
    

    }

@saninaimayer
Copy link

I have the same problem. I put the code suggest by @lostin70s and app receive and process notification in foreground ok but when the app is in background it is not ok. The message log when in background:

2017-09-06 19:09:30.879: <FIRMessaging/WARNING> FIRMessaging receiving notification in invalid state 2
2017-09-06 19:09:30.879693-0300[882:156235] Message ID: 0:1504735921747413%bd2dffcfbd2dffcf
2017-09-06 19:09:30.880030-0300[882:156235] {
aps = {
"content-available" = 1;
};
code = 945672;
"gcm.message_id" = "0:1504735921747413%bd2dffcfbd2dffcf";
message = "C\U00f3digo VEM 945672. Valor solicitado: 1.00";
type = "validation_code";
value = "1.00";
}

My iOS version is 10.3.3.

Please help-me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants