0

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);
    }

enter image description here

enter image description here

Raheel
  • 39
  • 6

1 Answers1

0

Sir David East's answer (https://stackoverflow.com/a/38226058/3231194) :

Go to Build Settings > Other Linker Flags > on a new line $(inherited).

Do a Cmd+Ctrl+K for a clean, and then build.


I also want to add these steps, rather than Cmd+Ctrl+K, it should be:

  1. Cmd+Shift+K. Then:
  2. Cmd+AltOption+Shift+K
  3. Finally, build it.
Glenn Posadas
  • 12,555
  • 6
  • 54
  • 95