修改
This commit is contained in:
@@ -172,6 +172,18 @@
|
||||
}];
|
||||
|
||||
NSLog(@"APNSToken = %@",[FIRMessaging messaging].APNSToken);
|
||||
|
||||
[[FIRMessaging messaging] tokenWithCompletion:^(NSString *token, NSError *error) {
|
||||
if (error) {
|
||||
NSLog(@"FCM Token 生成失败:%@", error.localizedDescription);
|
||||
// 常见错误:
|
||||
// - "Unable to resolve host":网络问题或 Firebase 服务器连接失败
|
||||
// - "Invalid project number":GoogleService-Info.plist 配置错误
|
||||
} else {
|
||||
NSLog(@"FCM Token:%@", token);
|
||||
// 验证 Token 有效性:在 Firebase 控制台用该 Token 发送测试消息
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,6 +192,11 @@
|
||||
return UIInterfaceOrientationMaskAll;
|
||||
}
|
||||
|
||||
// 注册推送失败的回调
|
||||
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
|
||||
NSLog(@"推送注册失败:%@", error.localizedDescription);
|
||||
}
|
||||
|
||||
- (void)messaging:(FIRMessaging *)messaging didReceiveRegistrationToken:(NSString *)fcmToken
|
||||
{
|
||||
NSLog(@"FCM registration token: %@", fcmToken);
|
||||
@@ -210,6 +227,8 @@
|
||||
|
||||
-(void)processWithNoti:(NSDictionary *)userInfo
|
||||
{
|
||||
|
||||
NSLog(@"Received the push notification");
|
||||
NSString *message = [userInfo objectForKey:@"message"];
|
||||
NSData *jsonData = [message dataUsingEncoding:NSUTF8StringEncoding];
|
||||
NSDictionary *messageNotiDic = nil;
|
||||
|
||||
Reference in New Issue
Block a user