quickstart-ios icon indicating copy to clipboard operation
quickstart-ios copied to clipboard

iOS 10 FCM code doesn't work (Xcode 8.0 GM)

Open Benjaminm5 opened this issue 10 years ago • 11 comments

The code at the bottom of the FCMSwift/AppDelegate.swift for Messaging handling on iOS10 doesn't work. If i try to build or run my app I get a Swift Compiler Error:

Command failed due to signal: Segmentation fault: 11

If i remove that code i don't get that error.

Benjaminm5 avatar Sep 19 '16 14:09 Benjaminm5

I got the same error.

lethianqt94 avatar Sep 20 '16 04:09 lethianqt94

Yea I got the same. When I remove all ios10 code from demo, it works fine...

SweetBloodyDuck avatar Sep 20 '16 08:09 SweetBloodyDuck

I've upgraded to Cocoa pod 1.0.1 and all seems to work.

nanonetAndroid avatar Sep 21 '16 15:09 nanonetAndroid

I'm using Cocoa pod 1.0.1, XCode Version 8.0 (8A218a) and having this error after upgrade: Ambiguous reference to member 'subscript' on line

print("Message ID: \(userInfo["gcm.message_id"]!)")

If you experience error, try executing pod update from Terminal. I just understand that cocoapods could be storing a local copy of pods and thus it only update if we run that command.

Make sure you see something like this:

Installing Firebase 3.6.0 (was 3.2.1)
Installing FirebaseAnalytics 3.4.2 (was 3.2.0)
Installing FirebaseInstanceID 1.0.8 (was 1.0.6)
Installing FirebaseMessaging 1.2.0 (was 1.1.0)

vinamelody avatar Sep 26 '16 06:09 vinamelody

I'm not seeing that error in xcode 8.1, so the linting may be fixed in the latest version.

ianbarber avatar Oct 06 '16 23:10 ianbarber

same here

choiks14 avatar Oct 10 '16 04:10 choiks14

This is solution. To be able to receive notification when the app in background. You must implement this method in your AppDelegate

**- (void)userNotificationCenter:(UNUserNotificationCenter )center didReceiveNotificationResponse:(UNNotificationResponse )response withCompletionHandler:(nonnull void (^)())completionHandler

This is my code snippet that works:

- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(nonnull void (^)())completionHandler
{
    // Print message ID.
    NSDictionary *userInfo = response.notification.request.content.userInfo;
    NSLog(@"Message ID: %@", userInfo[@"gcm.message_id"]);

    NSString* strURL = userInfo[@"URL"];
    NSString* strMessageTitle = [[[userInfo valueForKey:@"aps"] valueForKey:@"alert"] valueForKey:@"title"];
    NSString* strMessage = [[[userInfo valueForKey:@"aps"] valueForKey:@"alert"] valueForKey:@"body"];

    // Print full message.
    NSLog(@"%@", userInfo);
}

kiwi07 avatar Oct 11 '16 07:10 kiwi07

Thanks @vinamelody ! It's work for me !

jingchc avatar Oct 14 '16 07:10 jingchc

Updating Cocoapods to 1.0.1 doesn't fix this for me. Also the 8.1 beta doesn't fix the issue.

edit: Fixed it by putting use_frameworks in my pod file..

jordibruin avatar Oct 16 '16 19:10 jordibruin

Still getting segfaults in XCode 8.1

rickythefox avatar Nov 07 '16 20:11 rickythefox

Closing on the basis of use_frameworks! and updated cocoapods. If people are still getting an issue, probably easiest to file a new one with explicit error you're seeing at this point.

ianbarber avatar Dec 06 '16 22:12 ianbarber