注册

后台能收到好友发来的消息 是走的apns , didReceiveRemoteNotification不调用,messagesDidReceive也不调,那走哪个?

后台能收到好友发来的消息 是走的apns ,但- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 不调用,messagesDidReceive也不调,那走哪个?
已邀请:
在后台没超过3分钟走 messagesDidReceive
超过3分钟2个都不走,是离线消息
didReceiveRemoteNotification 是点击apns推送通知栏才走的方法。
后台3分钟前走messagedidrecrive,不走apns,回调可以放到appdelegate。之后走apns。
这个你的代理写了没有,有没有遵守协议,这个方法在远程的时候不走,你在appdelegate写之后,启动程序就回走的   if (options.displayStyle == EMPushDisplayStyleMessageSummary) {

        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];

要回复问题请先登录注册