1

I have followed google sample project to implement notification in iOS, However my app is crashing on following line,

[[FIRMessaging messaging] connectWithCompletion:^(NSError * _Nullable error)

The whole function is here to connect with Firebase Cloud Messaging(FCM),

 - (void)connectToFcm {
  [[FIRMessaging messaging] connectWithCompletion:^(NSError * _Nullable error) {
    if (error != nil) 
    {
      NSLog(@"Unable to connect to FCM. %@", error);
    } 
    else 
    {
      NSLog(@"Connected to FCM.");
    }
  }];
}

Error: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSData gtm_dataByGzippingData:]: unrecognized selector sent to class 0x10fd1f110'

Please help me! How can I solve this?

4

2 回答 2

1

go to Build Settings

find 'Other Linker Flags'

add '-ObjC'

this will fix your problem

于 2016-11-25T04:38:03.750 回答
0

check your platform version in your pod file

it will be like "platform :ios, '8.0'"

update the version to 9.0 and then run command pod install

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
target 'Product Listing' do
  pod 'Firebase/Messaging'
end
于 2016-06-03T20:01:54.203 回答