Sagar Unagar Sagar Unagar - 8 days ago 10
iOS Question

Unable to connect to FCM

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?

Answer

go to Build Settings

find 'Other Linker Flags'

add '-ObjC'

this will fix your problem

Comments