把之前可以正常推送的代码,拷贝过来,集成到项目中.
然后启动app后,是可以显示,提醒:
想要给您发送推送通知
通知可能包括提醒、声音和图形标记。这些可在设置中设置。
然后继续去调试,log输出:
2016-07-18 11:33:14.206 | JPUSH | I – [JPUSHService]
<span style="font-size: 12px; color: rgb(51, 51, 51); font-family: Monaco;"–<————————- JPush Log —————————-
<span style="font-size: 12px; color: rgb(51, 51, 51); font-family: Monaco;"–<——————JPush SDK Version:2.1.8–build:11———-
<span style="font-size: 12px; color: rgb(51, 51, 51); font-family: Monaco;"–<—————AppKey:724a7ab242e8d848c9aed9ef—————-
<span style="font-size: 12px; color: rgb(51, 51, 51); font-family: Monaco;"–<————————————————————–
2016-07-18 11:33:17.513 [Debug] [main] [AppDelegate.swift:493] listenRemotePush() >
2016-07-18 11:33:39.308 | JPUSH | I – [JPUSHClientController] Action – setup
2016-07-18 11:33:41.541 | JPUSH | W – [JPUSHClientController] Not get deviceToken yet. Maybe: your certificate not configured APNs? or current network is not so good so APNs registration failed? or there is no APNs register code? Please refer to JPush docs.
可能是因为在:
[记录]Xcode中重新设置使用企业开发者的Development的PP文件和证书
期间,重新之前同一个证书,重新导入了证书
但是没有重新基于新导入的证书去导出p12文件,JPUSH后台没有导入新的p12
而导致此处的问题?
那就去:
重新基于,之前删除后重新导入的证书:
去导出新的p12文件
期间,继续用之前的密码:
xxxApp
导出的p12文件:
com.xxx_APS_Dev.p12
去导入到JPUSH后台:
继续调试,执行到了:
didRegisterUserNotificationSettings
didRegisterForRemoteNotificationsWithDeviceToken
016-07-18 11:49:44.344 | JPUSH | I – [JPUSHSessionController] connecting with coreAddr 118.145.3.78,port 7002
2016-07-18 11:49:46.409 [Debug] [main] [AppDelegate.swift:429] networkDidSetup > 已连接 networkDidSetup notification=NSConcreteNotification 0x13f023060 {name = kJPUSHNetworkDidSetupNotification}
2016-07-18 11:49:46.593 | JPUSH | I – [JPUSHRegistration]
<span style="font-size: 12px; color: rgb(51, 51, 51); font-family: Monaco;"–<— register info —–
Appkey: 724a7ab242e8d848c9aed9ef
token:27b3528af7e64b06056c1524048f90e93dbf21f3bbc48a16ebf6c11da3852400
advertisingIdentifier:
2016-07-18 11:49:47.562 | JPUSH | I – [JPUSHRegistration]
<span style="font-size: 12px; color: rgb(51, 51, 51); font-family: Monaco;"–<— register result —–
uid: 5215065951
registrationID:13165ffa4e0901e54dc
2016-07-18 11:49:47.566 [Debug] [main] [AppDelegate.swift:437] networkDidRegister > 已注册 networkDidRegister notification=NSConcreteNotification 0x13f0b3c00 {name = kJPUSHNetworkDidRegisterNotification; userInfo = {
RegistrationID = 13165ffa4e0901e54dc;
}}
2016-07-18 11:49:47.568 [Debug] [main] [AppDelegate.swift:442] networkDidRegister > RegistrationID=13165ffa4e0901e54dc
2016-07-18 11:49:47.891 | JPUSH | I – [JPUSHLogin]
<span style="font-size: 12px; color: rgb(51, 51, 51); font-family: Monaco;"–<— login result —–
uid:5215065951
registrationID:13165ffa4e0901e54dc
2016-07-18 11:50:11.443 [Debug] [main] [AppDelegate.swift:452] networkDidLogin > 已登陆 networkDidLogin notification=NSConcreteNotification 0x13f0b4aa0 {name = kJPUSHNetworkDidLoginNotification}
2016-07-18 11:50:11.469 [Debug] [main] [AppDelegate.swift:455] networkDidLogin > registrationID=13165ffa4e0901e54dc
2016-07-18 11:50:35.693 | JPUSH | I – [JPUSHDeviceTokenReport] try to upload device token:27b3528af7e64b06056c1524048f90e93dbf21f3bbc48a16ebf6c11da3852400
networkDidLogin
第二次:
2016-07-18 11:52:19.130 | JPUSH | I – [JPUSHService]
<span style="font-size: 12px; color: rgb(51, 51, 51); font-family: Monaco;"–<————————- JPush Log —————————-
<span style="font-size: 12px; color: rgb(51, 51, 51); font-family: Monaco;"–<——————JPush SDK Version:2.1.8–build:11———-
<span style="font-size: 12px; color: rgb(51, 51, 51); font-family: Monaco;"–<—————AppKey:724a7ab242e8d848c9aed9ef—————-
<span style="font-size: 12px; color: rgb(51, 51, 51); font-family: Monaco;"–<————————————————————–
2016-07-18 11:52:19.133 [Debug] [main] [AppDelegate.swift:493] listenRemotePush() >
2016-07-18 11:52:19.134 | JPUSH | I – [JPUSHClientController] Action – setup
2016-07-18 11:52:19.681 [Debug] [main] [AppDelegate.swift:127] application(_:didRegisterForRemoteNotificationsWithDeviceToken:) > deviceToken=<27b3528a f7e64b06 056c1524 048f90e9 3dbf21f3 bbc48a16 ebf6c11d a3852400>
2016-07-18 11:52:25.062 [Debug] [main] [AppDelegate.swift:486] didRegisterRemoteNotification > 已注册远程通知 didRegisterRemoteNotification=(Function)
2016-07-18 11:52:25.063 [Debug] [main] [AppDelegate.swift:488] didRegisterRemoteNotification > deviceTokenStr=Optional(<27b3528a f7e64b06 056c1524 048f90e9 3dbf21f3 bbc48a16 ebf6c11d a3852400>)
2016-07-18 11:52:25.065 [Debug] [main] [AppDelegate.swift:160] application(_:didRegisterUserNotificationSettings:) > notificationSettings=<UIUserNotificationSettings: 0x10bc0aaf0; types: (UIUserNotificationTypeAlert UIUserNotificationTypeBadge UIUserNotificationTypeSound);>
2016-07-18 11:52:25.067 [Debug] [main] [AppDelegate.swift:160] application(_:didRegisterUserNotificationSettings:) > notificationSettings=<UIUserNotificationSettings: 0x10bc06880; types: (UIUserNotificationTypeAlert UIUserNotificationTypeBadge UIUserNotificationTypeSound);>
2016-07-18 11:52:25.067 [Debug] [main] [LoginRegisterViewController.swift2016-07-18 11:52:25.065 | JPUSH | W – [JPUSHClientController] Not get deviceToken yet. Maybe: your certificate not configured APNs? or current network is not so good so APNs registration failed? or there is no APNs register code? Please refer to JPush docs.
2016-07-18 11:52:25.333 | JPUSH | I – [JPUSHSessionController] connecting with coreAddr 113.31.80.153,port 7007
2016-07-18 11:52:25.367 [Debug] [main] [AppDelegate.swift:429] networkDidSetup > 已连接 networkDidSetup notification=NSConcreteNotification 0x10408ebd0 {name = kJPUSHNetworkDidSetupNotification}
2016-07-18 11:52:30.966 | JPUSH | I – [JPUSHLogin]
<span style="font-size: 12px; color: rgb(51, 51, 51); font-family: Monaco;"–<— login result —–
uid:5215065951
registrationID:13165ffa4e0901e54dc
2016-07-18 11:52:30.983 [Debug] [main] [AppDelegate.swift:452] networkDidLogin > 已登陆 networkDidLogin notification=NSConcreteNotification 0x104063240 {name = kJPUSHNetworkDidLoginNotification}
2016-07-18 11:52:30.985 [Debug] [main] [AppDelegate.swift:455] networkDidLogin > registrationID=13165ffa4e0901e54dc
2016-07-18 11:52:34.783 | JPUSH | I – [JPUSHDeviceTokenReport] try to upload device token:27b3528af7e64b06056c1524048f90e93dbf21f3bbc48a16ebf6c11da3852400
2016-07-18 11:52:35.174 | JPUSH | I – [JPUSHDeviceTokenReport] upload device token success
2016-07-18 11:55:59.828 [Info] [main] [MainViewController.swift:78] initJpush() > init jpush
2016-07-18 11:55:59.829 [Debug] [main] [MainViewController.swift:82] initJpush() > userIdAlias=10000010
2016-07-18 11:55:59.829 [Debug] [main] [MainViewController.swift:89] jpushSetAlias > userIdAlias=10000010
2016-07-18 11:56:01.810 [Debug] [main] [MainViewController.swift:102] aliasCallBack(_:tags:alias:) > resCode=0, tags=nil, alias=10000010
看起来是:
注册成功
且上传device token已成功了
-》应该可以接受推送了。
-》去JPUSH后台推送试试
然后Xcode中调试也收到了推送:
执行到了:
handleRemoteNotification
console输出:
2016-07-18 12:02:08.690 [Debug] [main] [AppDelegate.swift:509] handleRemoteNotification > remoteNotification=NSConcreteNotification 0x10c4ef820 {name = handleRemoteNotification; object = {
"_j_msgid" = 4044282063;
aps = {
alert = "test push to ios ";
badge = 1;
sound = default;
};
}}
然后再去:
强制杀掉app
看看能否收到推送,显示在iPhone上
好像iPhone中没有收到推送提醒。。。
去通知中确认,此app已经给了所有的消息的权限了:
不过看到了badge是1,所以至少从桌面上的app的图标的badge还是1,是无法看出此处推送是否已经到达的。。。
-》晕死,上面这次推送,忘了设置独立的alias。。。
这次,不会忘了:
不过iPhone手机端,过了一会,才收到:
对应的统计才出来:
且,iPhone锁屏界面中,拖动该消息后去解锁iPhone,可以打开对应的app(进入app的手势密码解锁页面):
然后再去添加代码,确保app内用户退出后,清除JPUSH的alias别名
然后再去测试,确保应该iPhone没法再收到推送