2017-11-14 19 views
0

私は自分のアプリケーションでfirebaseプッシュ通知を使用しました。私はSSL証明書を作成し、Firebaseプロジェクトにp.12ファイルを正しくアップロードしました。コードにエラーはありませんが、Firebaseから通知メッセージを送信すると完了メッセージが表示されますが、コンソールには次のように表示されます。IOSのプッシュ通知エラー

<Warning> [Firebase/Messaging][I-FCM002019] FIRMessaging received data-message, but FIRMessagingDelegate's-messaging:didReceiveMessage: not implemented

firebaseプッシュ通知のための私のコードはこれです:Firebase @import

#import "AppDelegate.h" 

。 @import FirebaseMessaging;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
// Override point for customization after application launch. 

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(tokenRefreshCallBack:) name:kFIRInstanceIDTokenRefreshNotification object:nil]; 

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(tokenRefreshCallBack:) name:kFIRInstanceIDTokenRefreshNotification object:nil]; 

UIUserNotificationType altype=(UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound); 
UIUserNotificationSettings *settings=[UIUserNotificationSettings settingsForTypes:altype categories:nil]; 

[application registerUserNotificationSettings:settings]; 
[application registerForRemoteNotifications]; 

[FIRApp configure]; 


return YES; 

}

- (void)applicationDidEnterBackground:(UIApplication *)application { 
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 

[FIRMessaging messaging]; 
NSLog(@"Disconnected from FCM"); 

}

- (void)applicationDidBecomeActive:(UIApplication *)application { 
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 
[self connectFirebase]; 

}

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{ 
NSLog(@"Message ID %@:",userInfo[@"gcm.message_id"]); 
NSLog(@"MMM %@",userInfo); 

}

-(void)tokenRefreshCallBack:(NSNotification *)notification{ 
NSString *token=[[FIRInstanceID instanceID]token]; 
NSLog(@"Token is %@",token); 
[self connectFirebase]; 

}

-(void)connectFirebase{ 
[[FIRMessaging messaging]connectWithCompletion:^(NSError *_Nullable error){ 
    if (error!=nil) { 
     NSLog(@"Unable to connect to FCM %@",error); 
    }else{ 
     NSLog(@"Connect to FCM"); 
    } 
}]; 

}

答えて

0

エラーメッセージを受信するFIRMessagingdelegate方法messaging:didReceiveMessage:を実装する必要があることを明確に述べています。

+0

私はそれをどのように実装するのか分からないのですか? @Shebuka – siddle

+0

'CMD'を' FIRMessaging'をクリックして実装に行くと、 'didReceiveMessage'が検索されます。 – Shebuka