I have intergrated firebase push notification in my app. I had installed cocoapods fine and do all the code in appdelegate.m file for firebase messaging. Also created certificate and uploaded to firebase to my project, i have followed all the procedure correctly but when i run the app i got some errors and app do not run and shows error while linking. My code for firebase is this,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FIRApp configure];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(tokenRefreshCallBack:) name:kFIRInstanceIDTokenRefreshNotification object:nil];
UIUserNotificationType type=(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound);
UIUserNotificationSettings *settings=[UIUserNotificationSettings settingsForTypes:type categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
return YES;
}
-(void)tokenRefreshCallBack:(NSNotification *)notification{
NSString *refreshToken=[[FIRInstanceID instanceID]token];
NSLog(@"Instance IDToken : %@",refreshToken);
[self connecttoFirebase];
}
-(void)connecttoFirebase{
[[FIRMessaging messaging]connectWithCompletion:^(NSError * _Nullable error){
if (error !=nil) {
NSLog(@"Unable to connect to FCM %@",error);
}else{
NSLog(@"Connected to FCM");
}
}];
}
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
NSLog(@"Message ID : %@",userInfo[@"gcm.message_id"]);
NSLog(@"%@",userInfo);
}