后台能收到好友发来的消息 是走的apns , didReceiveRemoteNotification不调用,messagesDidReceive也不调,那走哪个?
后台能收到好友发来的消息 是走的apns ,但- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 不调用,messagesDidReceive也不调,那走哪个?
没有找到相关结果
已邀请:
3 个回复
donghai
超过3分钟2个都不走,是离线消息
didReceiveRemoteNotification 是点击apns推送通知栏才走的方法。
[已注销]
一等到天幻
EMMessageBody *messageBody = message.body;
NSString *messageStr = nil;
switch (messageBody.type) {
根据messageBody.type 判断消息类型,
如果显示消息详情推送,按下面显示
if (message.chatType == EMChatTypeChatRoom){
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
NSString *key = [NSString stringWithFormat:@"OnceJoinedChatrooms_%@", [[EMClient sharedClient] currentUsername]];
NSMutableDictionary *chatrooms = [NSMutableDictionary dictionaryWithDictionary:[ud objectForKey:key]];
NSString *chatroomName = [chatrooms objectForKey:message.conversationId];
if(chatroomName){
}
}else{
messageStr = [NSString stringWithFormat:@"%@:%@", fromNameStr, messageStr];
}
notification.alertBody = [NSString stringWithFormat:@"%@", messageStr];
}else{
notification.alertBody = @"您有一条新消息";
}
notification.userInfo = @{@"msgtype":@(1),@"mid":@(0),@"f":message.from};
notification.alertAction = NSLocalizedString(@"open", @"Open");
notification.timeZone = [NSTimeZone defaultTimeZone];
notification.repeatInterval = 0;
if([[RKUserDefaults standardUserDefaults] boolForKey:VoiceKey]){
notification.soundName= UILocalNotificationDefaultSoundName;
}
//发送通知
[[UIApplication sharedApplication] scheduleLocalNotification:notification];