Sagar Unagar
Sagar Unagar

Reputation: 199

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?

Upvotes: 1

Views: 1632

Answers (2)

negaipro
negaipro

Reputation: 481

go to Build Settings

find 'Other Linker Flags'

add '-ObjC'

this will fix your problem

Upvotes: 1

Pratik
Pratik

Reputation: 433

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

Upvotes: 0

Related Questions