【发布时间】:2018-03-14 10:40:48
【问题描述】:
我在我的应用程序中集成了 firebase 推送通知。我已经很好地安装了 cocoapods,并在 appdelegate.m 文件中为 firebase 消息传递执行了所有代码。还创建了证书并上传到我的项目的firebase,我正确地遵循了所有程序,但是当我运行应用程序时,我遇到了一些错误并且应用程序没有运行并在链接时显示错误。我的 firebase 代码是这样的,
- (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);
}
【问题讨论】:
-
您的应用支持的最小 ios 版本是什么?
-
我的应用程序的 10.0 版本。 @AbdulKarim
-
我们可以看看你的 podfile 吗?您是否尝试通过注释掉您的 Firebase、pod install,然后再次取消注释 pod 和 pod install 来重新安装您的 Firebase pod?
-
我已经添加了屏幕截图检查。 @格伦
-
检查是否正常。 @格伦
标签: ios objective-c firebase