Die*_*ers 9 objective-c firebase-cloud-messaging
我试图从我的iOS-Objective-C应用程序发送一条消息:
NSInteger iTime = [NSDate timeIntervalSinceReferenceDate];
NSString *strID = [NSString stringWithFormat:@"%@%ld", setting.uid, (long)iTime];
NSDictionary *msg = @{@"title": @"My iOS-APP",
@"text": @"Message from the app"};
[[FIRMessaging messaging]sendMessage:msg to:setting.uid withMessageID:strID timeToLive:240];
Run Code Online (Sandbox Code Playgroud)
我的应用程序正确连接到AppDelegate中的FCM.但是在发送上面的消息时,几分钟后我收到以下错误:
Unable to connect to FCM. Error Domain=com.google.fcm Code=2001 "(null)"
Run Code Online (Sandbox Code Playgroud)
在最后几天搜索我发现了很多建议,但即使应用它们,我也没有成功发送消息.希望有人在那里有同样的问题,并找到了解决方案.
更新:在类中添加了通知:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendDataMessageFailure:) name:FIRMessagingSendErrorNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendDataMessageSuccess:) name:FIRMessagingSendSuccessNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didDeleteMessagesOnServer) name:FIRMessagingMessagesDeletedNotification object:nil];
Run Code Online (Sandbox Code Playgroud)
并得到反馈:
NSConcreteNotification 0x15df4f120 {
name = com.firebase.messaging.notif.send-success;
userInfo = {
messageID = ZisMh2OdBsVgjhUlWx9xKnZ3nTk1489164725;
}
}
Run Code Online (Sandbox Code Playgroud)
所以它接缝消息已发送,现在的问题是,如何检索消息,我认为它将作为推送通知传递。
| 归档时间: |
|
| 查看次数: |
8128 次 |
| 最近记录: |