Ios 什么情况下会出现OnReceiveMessage:返回的消息message中缺少messageJson字段、其余字段返回正常


#29

杀死算离线啊,你用我们的demo测一下看看,我们还提供了一个完整的JChat demo可以参考

「JChat下载(一个完整的即时通讯demo,包含Android、iOS(swift)、web)」


(CL9000) #30

你这是老的版本,最新的版本我看了
JChat-iOS-master中没有继承推送,但应用打开后可以收到消息,
杀死进程后外部没有推送弹框的IM(证书已配好的情况下)


(CL9000) #31
- (void)onSyncOfflineMessageConversation:(JMSGConversation *)conversation
                         offlineMessages:(NSArray<__kindof JMSGMessage *> *)offlineMessages 

开开应用这个方法不调用呢?为甚


(raoxd) #32

你杀掉进程,点击启动 APP,启动了之后就会有日志啊,我是想要日志看下,启动后是否有触发相关函数


(CL9000) #33

大哥 ,真机测试,杀掉进程后Xcode自动停止了,哪来的的日志呀


#34

不运行,你也可以看到日志


(CL9000) #35

好,但我这里面中文乱码怎么回事,: \M-e\M^\M-(\M-g\M-(\M^K\M-e\M-:\M^O\M-f\M-2\M-!\M-f\M^\M^I\M-h\M-?\M^P\M-h\M-!\M^L\M-g\M^Z\M^D\M-f\M^C\M^E\M-e\M^F\M-5\M-d\M-8\M^K\M-f\M^T\M-6\M-e\M^H\M-0\M-i\M^@\M^Z\M-g\M^\M-%\M-o\M-<\M^L\M-g\M^B\M-9\M-e\M^G\M-;\M-i\M^@\M^Z\M-g\M^\M-%\M-h\M-?\M^[\M-e\M^E\M-%\M-e\M-:\M^T\M-g\M^T\M-( : {

关于离线消息 杀掉进程:
1、有时候可以收到,有时候就收不到离线消息,


(CL9000) #36
默认	18:57:41.751486 +0800	 | JIGUANG | I - [JMSGClientController] Action - jmessage setup
默认	18:57:57.270964 +0800	 | JIGUANG | I - [JMessage+JMSGInner] Action - jmsg_clearCurrentUser
默认	19:04:06.841688 +0800	 | JIGUANG | I - [JMessage] this is official version SDK.
默认	19:04:12.474095 +0800	 | JIGUANG | D - [JMessage] Action - addDelegate::
默认	19:04:12.487871 +0800	 | JIGUANG | D - [JMessage] Action - jmsg_updateDBWithCompletionHandler:
默认	19:04:12.931860 +0800	 | JIGUANG | D - [JMessage] Action - setupJMessage:::::
默认	19:04:14.411854 +0800	 | JIGUANG | D - [JMSGDBManager] The current user db path: /var/mobile/Containers/Data/Application/7A0-B8EB-BC5853B055A9/Documents/MR04639_99904877/JMessage_MR04639757_99904877.db
默认	19:04:14.425193 +0800	 | JIGUANG | I - [JMSGClientController] 
------------------- JMessage SDK --------------------
------------------ JMessage SDK version:3.2.1, buildId:168 ---------
--------------------JCore Lib Version:1.1.5----------------------------
-----------------AppKey:fa500feeeef4f79d3----------------
----------------------------------------------------------------
默认	19:04:14.431774 +0800	 | JIGUANG | I - [JMSGClientController] Action - jmessage setup
默认	19:04:15.141613 +0800	 | JIGUANG | D - [JMessage+JMSGInner] Action - sendRequest - TCP
默认	19:04:35.887889 +0800	 | JIGUANG | D - [JMessage+JMSGInner] Action - sendRequest - TCP
默认	19:04:36.197567 +0800	 | JIGUANG | D - [JMessage+JMSGInner] Action - sendRequest - TCP
默认	19:04:36.343219 +0800	 | JIGUANG | D - [JMessage+JMSGInner] Action - jmsg_userLogoutClearAllCache
默认	19:04:36.392798 +0800	 | JIGUANG | I - [JMessage+JMSGInner] Action - jmsg_clearCurrentUser
默认	19:04:36.456823 +0800	 | JIGUANG | D - [JMessage] Action - jmsg_updateDBWithCompletionHandler:
默认	19:04:36.543225 +0800	 | JIGUANG | D - [JMSGDBManager] The current user db path: /var/mobile/Containers/Data/Application/7A0BF124-CF42-4981-B8EB-BC5853B055A9/Documents/MR04639757_99904877/JMessage_MR04639757_99904877.db
默认	19:04:40.601769 +0800	 | JIGUANG | D - [JMessage+JMSGInner] Action - sendRequest - TCP
默认	19:09:14.188599 +0800	apsd	2017-09-21 19:09:13 +0800 apsd[87]: <APSCourier: 0x16d69150>: Received message for enabled topic '' with payload '{
    "_j_business" = 32;
    "_j_msgid" = 432976053;
    "_j_type" = jmessage;
    "_j_uid" = 11073534859;
    aps =     {
        alert = "admin: 666vip777";
        badge = 1;
        sound = default;
    };
    custom =     {
    };
}' onInterface: NonCellular  for device token: NO  with priority (null)
默认	19:09:17.894920 +0800	iOS7及以上系统,收到通知:{
    "_j_business" = 32;
    "_j_msgid" = 432976053;
    "_j_type" = jmessage;
    "_j_uid" = 11073534859;
    aps =     {
        alert = "admin: 666vip777";
        badge = 1;
        sound = default;
    };
    custom =     {
    };
}
默认	19:09:18.993660 +0800	 | JIGUANG | I - [JMessage] this is official version SDK.
默认	19:09:27.028010 +0800	在程序没有运行的情况下收到通知,点击通知进入应用 : {
    "_j_business" = 32;
    "_j_msgid" = 432976053;
    "_j_type" = jmessage;
    "_j_uid" = 11073534859;
    aps =     {
        alert = "admin: 666vip777";
        badge = 1;
        sound = default;
    };
    custom =     {
    };
}
默认	19:09:28.083746 +0800	 | JIGUANG | D - [JMessage] Action - addDelegate::
默认	19:09:28.085470 +0800	 | JIGUANG | D - [JMessage] Action - jmsg_updateDBWithCompletionHandler:
默认	19:09:28.092705 +0800	 | JIGUANG | D - [JMessage] Action - setupJMessage:::::
默认	19:09:28.099009 +0800	 | JIGUANG | D - [JMSGDBManager] The current user db path: /var/mobile/Containers/Data/Application/815E3CD7-9E75-42F0-8A36-886A62FD82D7/Documents/MR04639_99904877/JMessage_MR04639757_99904877.db
默认	19:09:28.120291 +0800	 | JIGUANG | I - [JMSGClientController] 
------------------- JMessage SDK --------------------
------------------ JMessage SDK version:3.2.1, buildId:168 ---------
--------------------JCore Lib Version:1.1.5----------------------------
-----------------AppKey:fa500feeeef4f79d3----------------
----------------------------------------------------------------
默认	19:09:28.481184 +0800	 | JIGUANG | I - [JMSGClientController] Action - jmessage setup
默认	19:09:28.718589 +0800	 | JIGUANG | D - [JMessage+JMSGInner] Action - sendRequest - TCP
默认	19:09:42.493591 +0800	 | JIGUANG | D - [JMessage+JMSGInner] Action - sendRequest - TCP
默认	19:09:43.742514 +0800	 | JIGUANG | D - [JMessage+JMSGInner] Action - sendRequest - TCP
默认	19:09:47.452374 +0800	 | JIGUANG | D - [JMessage+JMSGInner] Action - jmsg_userLogoutClearAllCache
默认	19:09:47.603177 +0800	 | JIGUANG | I - [JMessage+JMSGInner] Action - jmsg_clearCurrentUser
默认	19:09:47.606085 +0800	 | JIGUANG | D - [JMessage] Action - jmsg_updateDBWithCompletionHandler:
默认	19:09:47.609228 +0800	 | JIGUANG | D - [JMSGDBManager] The current user db path: /var/mobile/Containers/Data/Application/815E3CD7-9E75-42F0-8A36-886A62FD82D7/Documents/MR04639757_99904877/JMessage_MR04639757_99904877.db
默认	19:09:52.668254 +0800	 | JIGUANG | D - [JMessage+JMSGInner] Action - sendRequest - TCP
默认	19:09:52.768484 +0800	 | JIGUANG | D - [JMessage+JMSGInner] Action - sendRequest - TCP

(CL9000) #37

1、

[JMessage addDelegate:self withConversation:nil];
        [JMessage setupJMessage:launchOptions
                         appKey:JMSSAGE_APPKEY
                        channel:CHANNEL
               apsForProduction:NO
                       category:nil
                 messageRoaming:YES];
        /// 极光PUSH
        [JPUSHService setupWithOption:launchOptions
                               appKey:JMSSAGE_APPKEY
                              channel:CHANNEL
                     apsForProduction:NO
                advertisingIdentifier:nil];

问题:都要写吗,如果推送和IM都需要的话,

2、

 [JMessage setupJMessage:launchOptions
                         appKey:JMSSAGE_APPKEY
                        channel:CHANNEL
               apsForProduction:NO
                       category:nil
                 messageRoaming:YES];

此方法会获取两次token,且不相同


#38

你给一下启动之后的日志,你不是说启动后没有离线消息吗,所以给这个时间的日志才能做分析啊。

下面这个产生了两个不一样的token的日志也提供一下。


(CL9000) #39

token

[JPUSHService registerDeviceToken:deviceToken];

[JMessage registerDeviceToken:deviceToken];

以下为启动日志:

2017-09-22 10:03:02.552355 mrmoney[2126:900774] [DYMTLInitPlatform] platform initialization successful
2017-09-22 10:03:03.052943 mrmoney[2126:900761]  | JIGUANG | I - [JIGUANGService] 
--------------------------- JPush Log ----------------------------
--------------------JPush SDK Version:3.0.6--build:40----------
--------------------JCore Lib Version:1.1.5--build:25----------
-----------------AppKey:fa500feeeef4f79d3----------------
----------------------------------------------------------------
2017-09-22 10:03:03.056037 mrmoney[2126:900759]  | JIGUANG | I - [JIGUANGClientController] Action - jpush setup
2017-09-22 10:03:03.058089 mrmoney[2126:900761]  | JIGUANG | I - [JIGUANGClientController] Action - setup
2017-09-22 10:03:03.063219 mrmoney[2126:900759]  | JIGUANG | I - [JMessage] Loaded currentUser info - (null)
2017-09-22 10:03:03.068647 mrmoney[2126:900759]  | JIGUANG | I - [JMessage] this is official version SDK.
2017-09-22 10:03:03.079758 mrmoney[2126:900759]  | JIGUANG | E - [JMSGStoreFileManager] Unexpected - username not exist, user:<JMSGUser, 0x17551d80> - [ARRAY - uid:0, username:<null>, nickname:<null>, noteName:<null>, noteText:<null>, gender:0, birthday:<null>, avatar:<null>, region:<null>, siganature:<null>, address:<null>, createTime:<null>, appKey:fa500feeeef4f79d3]
2017-09-22 10:03:03.081171 mrmoney[2126:900759]  | JIGUANG | W - [JMSGDBManager] Unexpected - username is nil
2017-09-22 10:03:03.084611 mrmoney[2126:900761]  | JIGUANG | E - [JMSGStoreFileManager] Unexpected - username not exist, user:<JMSGUser, 0x17551d80> - [ARRAY - uid:0, username:<null>, nickname:<null>, noteName:<null>, noteText:<null>, gender:0, birthday:<null>, avatar:<null>, region:<null>, siganature:<null>, address:<null>, createTime:<null>, appKey:fa500feeeef4f79d3]
2017-09-22 10:03:03.085886 mrmoney[2126:900759]  | JIGUANG | W - [JMSGDBManager] Unexpected - username is nil
2017-09-22 10:03:03.123039 mrmoney[2126:900761]  | JIGUANG | I - [JMSGClientController] 
------------------- JMessage SDK --------------------
------------------ JMessage SDK version:3.1.0, buildId:46 ---------
--------------------JCore Lib Version:1.1.5----------------------------
-----------------AppKey:fa500feeeef4f79d3----------------
----------------------------------------------------------------
2017-09-22 10:03:03.126413 mrmoney[2126:900759]  | JIGUANG | E - [JMessage+JMSGInner] user didn't login, please login first!
2017-09-22 10:03:03.128681 mrmoney[2126:900761]  | JIGUANG | E - [JMessage+JMSGInner] user didn't login, please login first!
2017-09-22 10:03:03.130442 mrmoney[2126:900761]  | JIGUANG | E - [JMessage+JMSGInner] user didn't login, please login first!
2017-09-22 10:03:03.132006 mrmoney[2126:900759]  | JIGUANG | E - [JMessage+JMSGInner] user didn't login, please login first!
2017-09-22 10:03:03.140414 mrmoney[2126:900659] succed
2017-09-22 10:03:03.233665 mrmoney[2126:900821] TalkingData: setSignalReportEnabled()#1
2017-09-22 10:03:03.238320 mrmoney[2126:900821] TalkingData: App Analytics SDK, Version:2.2.88;
2017-09-22 10:03:03.241389 mrmoney[2126:900821] TalkingData: Md5 is: TDOVC+a1fd4b233ce5228ff1e24f89ca71be51+TalkingData
2017-09-22 10:03:03.259979 mrmoney[2126:900821] TalkingData: App ID is 805CDFC2A9B4AE4BB909763D7071F9E;
2017-09-22 10:03:03.263105 mrmoney[2126:900821] TalkingData: Channel is iphone客户端;
2017-09-22 10:03:03.285738 mrmoney[2126:900759] TalkingData: Push start AppID: 805CDFC2A9B4AE4BB909763D7071F9E
2017-09-22 10:03:03.384217 mrmoney[2126:900659] socket连接成功
2017-09-22 10:03:03.623127 mrmoney[2126:900659] //Event - networkIsConnecting 正在连接中
2017-09-22 10:03:03.671519 mrmoney[2126:900659] ********1111111
2017-09-22 10:03:03.741788 mrmoney[2126:900848]  | JIGUANG | I - [JMSGClientController] Action - jmessage setup
2017-09-22 10:03:03.954011 mrmoney[2126:900659] My deviceToken is---------:1c871c7124de6eb73d73f938b053fce7fe41539ab2e9b3035f7858830d320
2017-09-22 10:03:04.230346 mrmoney[2126:900659] ---------设置极光Alias失败
2017-09-22 10:03:04.542610 mrmoney[2126:900849] TalkingData: send data to server
2017-09-22 10:03:04.619315 mrmoney[2126:900821] Reachability Flag Status: -R ------- networkStatusForFlags
2017-09-22 10:03:04.643131 mrmoney[2126:900821] IsLockKeySetted = no
2017-09-22 10:03:04.695373 mrmoney[2126:900848] PBItemCollectionServicer connection disconnected.
2017-09-22 10:03:07.558290 mrmoney[2126:900659] /var/mobile/Containers/Data/Application/4FDF7124-923E-441E-ACB0-2791DE26E610/Library/Caches
2017-09-22 10:03:07.571108 mrmoney[2126:900659] UMLOG: analytics sdk version 3.6.4 , app version 4.7.1
2017-09-22 10:03:07.578990 mrmoney[2126:900759] UMLOG: Request OC for updatetime body={"appkey":"5652885ee0f55a91ff0009a8","app_version":"4.7.1"}
2017-09-22 10:03:08.058026 mrmoney[2126:900659] wwFloatw: 28.844410
2017-09-22 10:03:08.058222 mrmoney[2126:900659] wFloat: 0.002683
2017-09-22 10:03:08.058606 mrmoney[2126:900659] angleH:0.051724
2017-09-22 10:03:08.124199 mrmoney[2126:900659] tabBar.frame: {{0, 526}, {320, 42}}
2017-09-22 10:03:08.126379 mrmoney[2126:900659] tabBar: <CLTabbar: 0x176fb630; frame = (0 526; 320 42); layer = <CALayer: 0x176fb890>>
2017-09-22 10:03:08.238986 mrmoney[2126:900659] UMLOG: session begin:4EAE209FBF61997771719519B8D23271
2017-09-22 10:03:08.282148 mrmoney[2126:900833]  | JIGUANG | E - [JIGUANGAddressController] not receive sis result just now
2017-09-22 10:03:08.660733 mrmoney[2126:900659] TalkingData: trackPageBegin()# trackPage begin pageName:产品列表首页
2017-09-22 10:03:09.264694 mrmoney[2126:900659] TalkingData: setDeviceToken: <1c871c71 24de6eb7 3d73f938 b053fce7 fe41539a b2e9b303 5f7877a5 8830d320>
2017-09-22 10:03:09.598766 mrmoney[2126:900659] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-09-22 10:03:09.603524 mrmoney[2126:900659] [MC] Reading from public effective user settings.
2017-09-22 10:03:09.672896 mrmoney[2126:900659] ********1111111
2017-09-22 10:03:09.675269 mrmoney[2126:900890] TalkingData: Push Start sending data.
2017-09-22 10:03:09.761912 mrmoney[2126:900659] My deviceToken is---------:1c871c7124de6eb73d73f938b053fce7fe41539ab2e9b3035f758830d320
2017-09-22 10:03:09.763611 mrmoney[2126:900659] ---------设置极光Alias失败
2017-09-22 10:03:09.799079 mrmoney[2126:900659] http://www.qianxsyl.com/mrMoney/wap/wapMeel=03
2017-09-22 10:03:09.799274 mrmoney[2126:900659] ----- http://www.qianxsyl.com/mrMoney/wap/wapMembennel=03
2017-09-22 10:03:09.918154 mrmoney[2126:900848]  | JIGUANG | I - [JIGUANGBadgeNumberReport] set badge:0 succeed
2017-09-22 10:03:09.947001 mrmoney[2126:900759] UMLOG: OC resp for updatetime: {
	oc_interval = 10,
	last_config_time = 1506045789873
}
2017-09-22 10:03:10.404057 mrmoney[2126:900830]  | JIGUANG | E - [JIGUANGAddressController] not receive sis result just now
2017-09-22 10:03:10.787185 mrmoney[2126:900890] TalkingData: Push Send data success!
2017-09-22 10:03:10.826979 mrmoney[2126:900783] WF: === Starting WebFilter logging for process mrmoney
2017-09-22 10:03:10.834037 mrmoney[2126:900783] WF: _userSettingsForUser mobile: {
	useContentFilter = 0,
	restrictWeb = 1,
	filterBlacklist = (
)
,
	filterWhitelist = (
)
,
	whitelistEnabled = 0,
	useContentFilterOverrides = 0
}
2017-09-22 10:03:10.834376 mrmoney[2126:900783] WF: _WebFilterIsActive returning: NO
2017-09-22 10:03:11.044217 mrmoney[2126:900832]  | JIGUANG | I - [JIGUANGSessionController] connecting with coreAddr 139.198.4.191,port 7001
2017-09-22 10:03:11.237487 mrmoney[2126:900762] TalkingData: TDRequestSessionTerminateAndLaunch send data success!
2017-09-22 10:03:11.320543 mrmoney[2126:900659] //Event - networkDidSetup 建立连接
2017-09-22 10:03:11.320695 mrmoney[2126:900659] //Event - networkDidSetup 建立连接
2017-09-22 10:03:11.559780 mrmoney[2126:900849]  | JIGUANG | I - [JIGUANGLogin] 
----- login result -----
uid:11082347591 
registrationID:1a1018970a9dd24efa
2017-09-22 10:03:11.563065 mrmoney[2126:900759] UMLOG: Response OnlineConfig: {
	online_params = {
},
	oc_interval = 10,
	ad_request = 1,
	config_update = Yes,
	last_config_time = 1506045791522,
	report_policy = 1
}
2017-09-22 10:03:11.607800 mrmoney[2126:900659] UMLOG: (online_params) {
}
2017-09-22 10:03:11.608579 mrmoney[2126:900659] online config has fininshed and note = {
}
2017-09-22 10:03:11.710245 mrmoney[2126:900762]  | JIGUANG | I - [JIGUANGDeviceTokenReport] try to upload device token:1c871c7124de6eb73d73f938b053fce7fe41539ab9b3035f7877a58830d320
2017-09-22 10:03:11.960181 mrmoney[2126:900892]  | JIGUANG | E - [JMessage+JMSGInner] user didn't login, please login first!
2017-09-22 10:03:11.960491 mrmoney[2126:900659] //Event - networkDidLogin 连接成功
2017-09-22 10:03:11.960620 mrmoney[2126:900659] //Event - networkDidLogin 连接成功
2017-09-22 10:03:12.060089 mrmoney[2126:900762]  | JIGUANG | I - [JIGUANGDeviceTokenReport] upload device token success
2017-09-22 10:03:15.084135 mrmoney[2126:900818] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)
2017-09-22 10:03:16.016217 mrmoney[2126:900659] com.ogin///account%7C=%7C80198dd9-4eae-487b-96d3-c991674b83c6%7C*%7CpassCisVisitor%7C=%7C1
2017-09-22 10:03:16.017301 mrmoney[2126:900659] -----------------match水水水水:account|=|80198dd9-4eae-487b-96d3-c991674b83c6|*|password|=|123456|*|isVisitor|=|1------------
2017-09-22 10:03:16.020627 mrmoney[2126:900659] {
    username = 80198dd9-4eae-487b-96d3-c991674bc6;
    password = 126;
    deviceId = IPHONE1c871c7124de6eb73d73f938b053fce7fe41539ab2e9b3035f7877a58830d320;
    signBody = 26F7B38B801EED1F60813F7DAA2F0386;
}

2017-09-22 10:03:17.422885 mrmoney[2126:900659] send.... 125
2017-09-22 10:03:17.424069 mrmoney[2126:900659] *************************** SEND MESSAGE index = 0 ********************************
2017-09-22 10:03:17.424791 mrmoney[2126:900659] onSocketDidDisconnect
2017-09-22 10:03:17.425521 mrmoney[2126:900659] succed
2017-09-22 10:03:18.372381 mrmoney[2126:900659] send.... 1
2017-09-22 10:03:18.372975 mrmoney[2126:900659] *************************** SEND MESSAGE index = 0 ********************************
2017-09-22 10:03:18.424011 mrmoney[2126:900659] socket连接成功
2017-09-22 10:03:18.800497 mrmoney[2126:900659] didReadData from type = 1
2017-09-22 10:03:18.800662 mrmoney[2126:900659] *************************** READ MESSAGE index = 0 ********************************
2017-09-22 10:03:18.802894 mrmoney[2126:900659] logB.success=true
2017-09-22 10:03:18.803092 mrmoney[2126:900659] logB.token = VI00016183

2017-09-22 10:03:23.452665 mrmoney[2126:900659] updateLastLoginTime search Result:{"result":"0"}
2017-09-22 10:04:18.373838 mrmoney[2126:900659] send.... 123
2017-09-22 10:04:18.375190 mrmoney[2126:900659] *************************** SEND MESSAGE index = 0 ********************************

#40

这里的日志显示 你应该是不仅仅杀死了进程还是 退出了登录后杀死的进程吧?


(CL9000) #41

我是直接杀掉的,发现,调用此方法:

我的应用,会在获取一次token ,且会变,注释掉就正常呢?是有冲突吗,,,为什么会启动第二次去获取token


#42

你如果是直接杀掉后重启启动,怎么会报未登录?

JPush本就已经注册过了一次,JMessage里面就不会再去注册获取token了。


(CL9000) #43

以下是在APPdelegate中的代码:
``
/// 极光PUSH
[JPUSHService setupWithOption:launchOptions
appKey:JMSSAGE_APPKEY
channel:CHANNEL
apsForProduction:NO
advertisingIdentifier:nil];
/// 极光IM
[JMessage addDelegate:self withConversation:nil];
// [JMessage setupJMessage:launchOptions
// appKey:JMSSAGE_APPKEY
// channel:CHANNEL
// apsForProduction:NO
// category:nil
// messageRoaming:NO];

self.pushchanel = PUSHCHANNEL_JPUSH; /// weicl极光渠道
user_defaults_set_int(@“pushchanel”,self.pushchanel);
switch(self.pushchanel) {
case PUSHCHANNEL_JPUSH: ///–极光推送收取消息
{
// [self configJMessageandpush]; /// 极光IM JPush注册
if ([[MessageScoket defaultInstance] isConnected]) {
[[MessageScoket defaultInstance] disConnect];
}
} break;
case PUSHCHANNEL_SELFPUSH: /// 自己服务器推送和聊天 - 基于socket
{
dispatch_async(dispatch_get_main_queue(), ^{
[self regestnotification];
});
} break;
}
if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init];
entity.types = UNAuthorizationOptionAlert|UNAuthorizationOptionBadge|UNAuthorizationOptionSound;
[JPUSHService registerForRemoteNotificationConfig:entity delegate:self];
} else if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
// 可以添加自定义categories
[JPUSHService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |
UIUserNotificationTypeSound |
UIUserNotificationTypeAlert)
categories:nil];
} else {
// categories 必须为nil
[JPUSHService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)
categories:nil];
}

[JPUSHService setBadge:user_defaults_get_int(UN_READ_KEFU) + user_defaults_get_int(UN_READ_SYSTEM)+user_defaults_get_int(UN_READ_YOULIKE)+user_defaults_get_int(UN_READ_DYNAMICFUNDS)];

[JPUSHService setAlias:userMID() completion:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) {
    //---为0 是成功否则失败
    if(iResCode==0){
        NSLog(@"---------设置极光Alias成功iAlias: %@, seq: %ld", iAlias, (long)seq);
    }else{
        NSLog(@"---------设置极光Alias失败");
    }
} seq:10001]; ///weicl极光请求时传入的序列号,会在回调时原样返回


NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
[defaultCenter addObserver:self selector:@selector(networkDidSetup:) name:kJMSGNetworkDidSetupNotification object:nil];
[defaultCenter addObserver:self selector:@selector(networkIsConnecting:) name:kJMSGNetworkIsConnectingNotification object:nil];
[defaultCenter addObserver:self selector:@selector(networkDidClose:) name:kJMSGNetworkDidCloseNotification object:nil];
[defaultCenter addObserver:self selector:@selector(networkDidRegister:) name:kJMSGNetworkDidRegisterNotification object:nil];
[defaultCenter addObserver:self selector:@selector(networkDidLogin:) name:kJMSGNetworkDidLoginNotification object:nil];
[defaultCenter addObserver:self selector:@selector(receivePushMessage:) name:kJMSGNetworkDidReceiveMessageNotification object:nil];

[self LoginJpushandJMessage];

``
/// 极光登录 IM(注册)

  • (void)LoginJpushandJMessage
    {
    // [Common showAlertWithTitle:@“登录IM” content:@“登录IM119”];
    if (isUserLogin())
    { /// 极光原来传递的密码为真实密码 替换
    [JMSGUser loginWithUsername:userMID() password:user_defaults_get_string(JM_PASSWORD) completionHandler:^(id resultObject, NSError *error)
    {
    //—登陆失败,没注册(需要注册)
    if (!resultObject && error.code == 801003)
    {
    //–注册极光IM
    [JMSGUser registerWithUsername:userMID() password:user_defaults_get_string(JM_PASSWORD) completionHandler:^(id resultObject, NSError *error)
    {
    if(error) {
    NSLog(@"--------------极光IM00注册失败 :%ld --:%@",(long)error.code, error.description);
    } else {
    /// 注册极光IM成功 ///-----登陆极光IM
    [JMSGUser loginWithUsername:userMID() password:user_defaults_get_string(JM_PASSWORD) completionHandler:^(id resultObject, NSError *error)
    {
    if (!error) {
    // [Common showAlertWithTitle:@“登录IM” content:@“登录IM成功119-1”];
    NSLog(@"–注册极光IM成功—极光IM登陆成功_00\n–:%ld \n",(long)error.code);
    [self setnickname];
    }
    }];
    }
    }];
    } else {
    // [Common showAlertWithTitle:@“登录IM” content:@“登录IM成功119-0”];
    NSLog(@"------极光IM00登陆成功:–%ld",(long)error.code);
    [self setnickname];
    }
    }];
    }
    }

(CL9000) #44

有个问题:
1、杀掉进程后,我重启应用,怎么也走获取token的方法???
2、原来的未登录是因为我的用户ID为空的


#45

每次启动都去获取一次token没有什么问题,可以保证在Apple服务器认为你token失效时及时取到新的token

那你重新登录后,离线消息什么的走了吗?如果之前有离线消息的话


(CL9000) #46

离线消息在应用打开正常,杀掉进程在进我还未处理,

2、按说一个应用不会每次杀掉进程进入应用token都会变的呀
我通同时用了推送和IM, 以下代码会改变我的token,,我这样写没错呀

if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
        JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init];
        entity.types = UNAuthorizationOptionAlert|UNAuthorizationOptionBadge|UNAuthorizationOptionSound;
        [JPUSHService registerForRemoteNotificationConfig:entity delegate:self];
    } else if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
        // 可以添加自定义categories
        [JPUSHService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |
                                                          UIUserNotificationTypeSound |
                                                          UIUserNotificationTypeAlert)
                                              categories:nil];
    } else {
        // categories 必须为nil
        [JPUSHService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
                                                          UIRemoteNotificationTypeSound |
                                                          UIRemoteNotificationTypeAlert)
                                              categories:nil];
    }

#47

每次都会变?不会吧?

没遇到这样的情况啊。下面这个只是添加category的,不影响token啊。


(CL9000) #48

**jpush 3.0.1
Jmessage 3.2.1
jcore 1.1.5
**
我开始JMessage .framework中有个jcore,.我直接拿到外面会有影响吗