iOS 手机处于前台收不到推送通知,但是处于手机处于后台可以收到

hbuilder
jpush
收不到消息
标签: #<Tag:0x00007fb831921828> #<Tag:0x00007fb831921558> #<Tag:0x00007fb831921260>

(freedemons) #1

问题背景:参考jpush-hbuilder-demo进行集成,并非专职ios开发集成得很心累,好不容易集成成功,(判断标志是控制台显示: upload device token success, token is : xxxxxx)。

如题,iOS 手机处于前台收不到推送通知,但是处于手机处于后台可以收到,并且自定义消息也可以收到。

这里指的前台通知收不到是真的收不到,我已经有打日志了,如果前台有信息到达会有日志的。
registrationID:101d85590942f24cdc3


(freedemons) #2

官方的小哥哥呢


#3

iOS 10 以下系统,apns 通知,在前台时收到,本身就是不展示的,该类问题可以优先搜索

关于通知的特性,详细阅读:

如果连日志也没有打印,请提供你的消息的 msgid 。

并建议使用 demo 测试,看 demo 收消息的效果与所走的方法。


(freedemons) #5

小哥哥 我知道是不显示,我问题描述也提及了。我在接收前台通知事件打日志都没有触发,说明没有根本没有触发。况且测试机是ios10以上的系统。


(freedemons) #6

这是其中一条msgid:1186465310
demo的我也运行过好多遍了,效果跟办法我都知道,但微臣就是做不到。


#7

我对该消息的查询结果是:

极光服务器已经将消息成功的发送给了 Apple 服务器。

你说的[quote=“freedemons, post:6, topic:22969”]
demo的我也运行过好多遍了,效果跟办法我都知道,但微臣就是做不到。
[/quote]

意思是 demo 在前台可以成功收到消息,但是你的项目不行?

1、你集成的 SDK 的版本号是多少?xcode 版本是多少?
2、你是否有实现设置alert

// iOS 10 Support
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center  willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler {
  // Required
  NSDictionary * userInfo = notification.request.content.userInfo;
  if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
    [JPUSHService handleRemoteNotification:userInfo];
  }
  else {
     // 本地通知
  }
  completionHandler(UNNotificationPresentationOptionAlert); // 需要执行这个方法,选择是否提醒用户,有Badge、Sound、Alert三种类型可以选择设置
}

3、将你客户端完整的日志提供上来。


(freedemons) #8

1、JPush SDK Version:2.1.7–build:
XCODE版本:xcode9.1

2、我是参考jpush-hbuilder-demo上面的文档指示进行集成,该demo运行可以收到,而我集成后运行无法监听到前台收到通知事件,其余正常。

3、日志很多我也分不清哪些是您需要的。

Dec  4 10:31:56 FREEDEMONS locationd[59] <Notice>: {"msg":"adapter details", "adaperDescription":"usb host", "batteryChargerType":"kChargerTypeUsb"}
Dec  4 10:31:56 FREEDEMONS locationd[59] <Notice>: {"msg":"battery capacity info", "batteryStatus":"{"level":99.000000, "charged":false, "connected":true, "chargerType":"kChargerTypeUsb", "wasConnected":false", "":"", "currentCapacity":"1584", "maximumCapacity":"1600", "batteryIsDifferent":"0"}
Dec  4 10:31:56 FREEDEMONS coreduetd[87] <Notice>: CDDBatteryMonitor:	received batterycallback, currentPercentage:99.000000!
Dec  4 10:32:01 FREEDEMONS locationd[59] <Notice>: message 'kCLConnectionMessageWatchdog' received from client '/System/Library/PrivateFrameworks/WirelessDiagnostics.framework'
Dec  4 10:32:01 FREEDEMONS locationd[59] <Notice>: message 'kCLConnectionMessageWatchdog' received from client 'com.apple.locationd'
Dec  4 10:32:02 FREEDEMONS locationd[59] <Notice>: message 'kCLConnectionMessageWatchdog' received from client '/System/Library/PrivateFrameworks/PassKitCore.framework'
Dec  4 10:32:02 FREEDEMONS locationd[59] <Notice>: message 'kCLConnectionMessageWatchdog' received from client '/System/Library/LocationBundles/PassbookRelevancy.bundle'
Dec  4 10:32:02 FREEDEMONS locationd[59] <Notice>: message 'kCLConnectionMessageWatchdog' received from client '/System/Library/PrivateFrameworks/PassKitCore.framework'
Dec  4 10:32:04 FREEDEMONS locationd[59] <Notice>: message 'kCLConnectionMessageWatchdog' received from client '/System/Library/Frameworks/CoreTelephony.framework'
Dec  4 10:32:04 FREEDEMONS locationd[59] <Notice>: message 'kCLConnectionMessageWatchdog' received from client '/System/Library/LocationBundles/TimeZone.bundle'
Dec  4 10:32:05 FREEDEMONS locationd[59] <Notice>: message 'kCLConnectionMessageWatchdog' received from client '/System/Library/LocationBundles/WifiCalling.bundle'
Dec  4 10:32:07 FREEDEMONS locationd[59] <Notice>: {"msg":"client getting effective client name", "clientName":"/usr/sbin/wifid", "bundleId":"", "bundlePath":"/System/Library/PrivateFrameworks/MobileWiFi.framework"}
Dec  4 10:32:07 FREEDEMONS locationd[59] <Notice>: message 'kCLConnectionMessageWatchdog' received from client '/System/Library/PrivateFrameworks/MobileWiFi.framework'
Dec  4 10:32:07 FREEDEMONS symptomsd(SymptomEvaluator)[112] <Notice>: CFSM Current state: idle, changed: txThresholded to 1 for net type 1, eligible for alerted but constraints unsatisfied (1,0,0,0)
Dec  4 10:32:07 FREEDEMONS symptomsd(SymptomEvaluator)[112] <Notice>: CFSM Current state: idle, changed: txThresholded to 1 for net type 1, ineligible for committed as nil pred, wifi (0x0) cell (0x0)
Dec  4 10:32:07 FREEDEMONS symptomsd(SymptomEvaluator)[112] <Notice>: CFSM Relays: cell (active-no/primary-no/knowngood-no/rssithresh-ok/txthresh-ok/arp-ok/dns-ok/tcp-ok/lqm:-2/advisory:0) wifi (active/primary/knowngood-no/rssithresh-ok/txthresh-err/arp-ok/dns-ok/tcp-ok/lqm:100/advisory:7)
Dec  4 10:32:08 FREEDEMONS mstreamd(MediaStream)[2829] <Notice>: Monitoring for external power.
Dec  4 10:32:08 FREEDEMONS mstreamd(MediaStream)[2829] <Notice>: Media stream daemon stopping.
Dec  4 10:32:08 FREEDEMONS mstreamd(MediaStream)[2829] <Notice>: <MSIOSAlbumSharingDaemon: 0x13dd638b0>: Shutting down state machine for personID 8347410657.
Dec  4 10:32:08 FREEDEMONS mstreamd(MediaStream)[2829] <Notice>: <MSASStateMachine: 0x13dd851f0>: Shutting down uploader.
Dec  4 10:32:08 FREEDEMONS mstreamd(MMCS)[2829] <Notice>: Closing mmcs (0x13de328a0)
Dec  4 10:32:08 FREEDEMONS mstreamd(MMCS)[2829] <Notice>: Waiting for mmcs job queue
Dec  4 10:32:08 FREEDEMONS mstreamd(MMCS)[2829] <Notice>: mmcs job queue halted
Dec  4 10:32:08 FREEDEMONS mstreamd(MMCS)[2829] <Notice>: === Read Stream Pool icloud_pool_ stats
	total connections: 0
	   total requests: 0
	     still in use: 0
Dec  4 10:32:08 FREEDEMONS mstreamd(MMCS)[2829] <Notice>: === Read Stream Pool vendor_pool_ stats
	total connections: 0
	   total requests: 0
	     still in use: 0
Dec  4 10:32:08 FREEDEMONS mstreamd(MMCS)[2829] <Notice>: upload statistics
Queue Depth Distribution
  Depth Count
In-flight Request Count Distribution
  Depth Count


download statistics
Queue Depth Distribution
  Depth Count
In-flight Request Count Distribution
  Depth Count


background-upload statistics
Queue Depth Distribution
  Depth Count
In-flight Request Count Distribution
  Depth Count


background-download statistics
Queue Depth Distribution
  Depth Count
In-flight Request Count Distribution
  Depth Count
Dec  4 10:32:08 FREEDEMONS mstreamd(MediaStream)[2829] <Notice>: <MSASStateMachine: 0x13dd851f0>: Shutting down downloader.
Dec  4 10:32:08 FREEDEMONS mstreamd(MMCS)[2829] <Notice>: Closing mmcs (0x13de3b1b0)
Dec  4 10:32:08 FREEDEMONS mstreamd(MMCS)[2829] <Notice>: Waiting for mmcs job queue
Dec  4 10:32:08 FREEDEMONS mstreamd(MMCS)[2829] <Notice>: mmcs job queue halted
Dec  4 10:32:08 FREEDEMONS mstreamd(MMCS)[2829] <Notice>: === Read Stream Pool icloud_pool_ stats
	total connections: 0
	   total requests: 0
	     still in use: 0
Dec  4 10:32:08 FREEDEMONS mstreamd(MMCS)[2829] <Notice>: === Read Stream Pool vendor_pool_ stats
	total connections: 0
	   total requests: 0
	     still in use: 0
Dec  4 10:32:08 FREEDEMONS mstreamd(MMCS)[2829] <Notice>: upload statistics
Queue Depth Distribution
  Depth Count
In-flight Request Count Distribution
  Depth Count


download statistics
Queue Depth Distribution
  Depth Count
In-flight Request Count Distribution
  Depth Count


background-upload statistics
Queue Depth Distribution
  Depth Count
In-flight Request Count Distribution
  Depth Count


background-download statistics
Queue Depth Distribution
  Depth Count
In-flight Request Count Distribution
  Depth Count
Dec  4 10:32:08 FREEDEMONS mstreamd(MediaStream)[2829] <Notice>: <MSASStateMachine: 0x13dd851f0>: Shutting down state machine.
Dec  4 10:32:08 FREEDEMONS mstreamd(MediaStream)[2829] <Notice>: <MSASServerSideModel: 0x13dd7ef90>: Command Queue has shut down.
Dec  4 10:32:08 FREEDEMONS mstreamd(MediaStream)[2829] <Notice>: <MSIOSAlbumSharingDaemon: 0x13dd638b0>: Shared Streams daemon has shut down.
Dec  4 10:32:08 FREEDEMONS mstreamd(MediaStream)[2829] <Notice>: mstreamd shutting down.
Dec  4 10:32:08 FREEDEMONS apsd(PersistentConnection)[83] <Notice>: 2017-12-04 10:32:08 +0800 apsd[83]: peer(2829) received XPC_ERROR_CONNECTION_INVALID
Dec  4 10:32:08 FREEDEMONS apsd(PersistentConnection)[83] <Notice>: 2017-12-04 10:32:08 +0800 apsd[83]: peer(2829) received XPC_ERROR_CONNECTION_INVALID
Dec  4 10:32:08 FREEDEMONS apsd(PersistentConnection)[83] <Notice>: 2017-12-04 10:32:08 +0800 apsd[83]: peer(2829) received XPC_ERROR_CONNECTION_INVALID
Dec  4 10:32:08 FREEDEMONS apsd(PersistentConnection)[83] <Notice>: 2017-12-04 10:32:08 +0800 apsd[83]: peer(2829) received XPC_ERROR_CONNECTION_INVALID
Dec  4 10:32:08 FREEDEMONS identityservicesd[47] <Notice>: localObjectDiedNotification: <private>
Dec  4 10:32:08 FREEDEMONS identityservicesd[47] <Notice>: Removing listener ID: <private>
Dec  4 10:32:08 FREEDEMONS identityservicesd[47] <Notice>: Cleaning up session(s) for client ID: <private> because it died
Dec  4 10:32:08 FREEDEMONS UserEventAgent(PersistentConnection)[22] <Notice>: 2017-12-04 10:32:08 +0800 UserEventAgent[22] BTA-com.apple.timed: Invalidating simple timer <PCSimpleTimer: 0x1032069b0>
Dec  4 10:32:08 FREEDEMONS UserEventAgent(PersistentConnection)[22] <Notice>: 2017-12-04 10:32:08 +0800 UserEventAgent[22]: <PCDispatchTimer: 0x1002fa690> is invalidated 
Callstack (
	0   PersistentConnection                0x000000018f5ba0cc <redacted> + 116
	1   PersistentConnection                0x000000018f5b7aac <redacted> + 292
	2   com.apple.BackgroundTaskAgentPlugin 0x0000000100703b68 com.apple.BackgroundTaskAgentPlugin + 15208
	3   com.apple.BackgroundTaskAgentPlugin 0x0000000100702dbc com.apple.BackgroundTaskAgentPlugin + 11708
	4   com.apple.BackgroundTaskAgentPlugin 0x00000001007029a8 com.apple.BackgroundTaskAgentPlugin + 10664
	5   libdispatch.dylib                   0x000000018b6d29a0 <redacted> + 16
	6   libdispatch.dylib                   0x000000018b6df604 <redacted> + 448
	7   libdispatch.dylib                   0x000000018b6ebc1c <redacted> + 204
	8   libdispatch.dylib                   0x000000018b6d48a0 <redacted> + 804
	9   libdispatch.dylib                   0x000000018b6e0964 <redacted> + 560
	10  libdispatch.dylib                   0x000000018b6d62cc <\M-b\M^@\M-&>
Dec  4 10:32:08 FREEDEMONS UserEventAgent(PersistentConnection)[22] <Notice>: 2017-12-04 10:32:08 +0800 UserEventAgent[22]: <PCDispatchTimer: 0x1002fa690> dealloced
Dec  4 10:32:08 FREEDEMONS UserEventAgent(PersistentConnection)[22] <Notice>: 2017-12-04 10:32:08 +0800 UserEventAgent[22]: <PCDispatchTimer: 0x1002f21a0> is invalidated 
Callstack (
	0   PersistentConnection                0x000000018f5ba0cc <redacted> + 116
	1   PersistentConnection                0x000000018f5b7ac8 <redacted> + 320
	2   com.apple.BackgroundTaskAgentPlugin 0x0000000100703b68 com.apple.BackgroundTaskAgentPlugin + 15208
	3   com.apple.BackgroundTaskAgentPlugin 0x0000000100702dbc com.apple.BackgroundTaskAgentPlugin + 11708
	4   com.apple.BackgroundTaskAgentPlugin 0x00000001007029a8 com.apple.BackgroundTaskAgentPlugin + 10664
	5   libdispatch.dylib                   0x000000018b6d29a0 <redacted> + 16
	6   libdispatch.dylib                   0x000000018b6df604 <redacted> + 448
	7   libdispatch.dylib                   0x000000018b6ebc1c <redacted> + 204
	8   libdispatch.dylib                   0x000000018b6d48a0 <redacted> + 804
	9   libdispatch.dylib                   0x000000018b6e0964 <redacted> + 560
	10  libdispatch.dylib                   0x000000018b6d62cc <\M-b\M^@\M-&>
Dec  4 10:32:08 FREEDEMONS UserEventAgent(PersistentConnection)[22] <Notice>: 2017-12-04 10:32:08 +0800 UserEventAgent[22]: <PCDispatchTimer: 0x1002f21a0> dealloced
Dec  4 10:32:08 FREEDEMONS UserEventAgent(PersistentConnection)[22] <Notice>: 2017-12-04 10:32:08 +0800 UserEventAgent[22]: Disabling power monitoring for <PCSimpleTimer: 0x1032069b0> - 2 timers
Dec  4 10:32:08 FREEDEMONS UserEventAgent(PersistentConnection)[22] <Notice>: 2017-12-04 10:32:08 +0800 UserEventAgent[22] BTA-com.apple.mediastream.mstreamd: Started simple timer <PCSimpleTimer: 0x1002f8a70> with fire date [2017-12-04 10:32:18 +0800]
Dec  4 10:32:08 FREEDEMONS UserEventAgent(PersistentConnection)[22] <Notice>: 2017-12-04 10:32:08 +0800 UserEventAgent[22]: <PCDispatchTimer: 0x1003df220> initialized with target <PCSimpleTimer: 0x1002f8a70> selector _preventSleepFired timerSource <OS_dispatch_source: 0x103402500>
Dec  4 10:32:08 FREEDEMONS UserEventAgent(PersistentConnection)[22] <Notice>: 2017-12-04 10:32:08 +0800 UserEventAgent[22]: <PCDispatchTimer: 0x10032ab80> initialized with target <PCSimpleTimer: 0x1002f8a70> selector _fireTimerFired timerSource <OS_dispatch_source: 0x1003968e0>
Dec  4 10:32:08 FREEDEMONS UserEventAgent(PersistentConnection)[22] <Notice>: 2017-12-04 10:32:08 +0800 UserEventAgent[22] BTA-com.apple.mediastream.mstreamd: <PCSimpleTimer: 0x1002f8a70> created preventSleepTimer <PCDispatchTimer: 0x1003df220> and fireTimer <PCDispatchTimer: 0x10032ab80> on queue <OS_dispatch_queue: PCSimpleTimer-timerQ[0x1003e1280]>

(freedemons) #9

已回复
不知道有没有通知你


#10

升级你的 SDK 版本,支持 iOS 10 新特性的从 2.1.9 开始,完全适配 xcode 9不会报错的,用最新的 SDK 3.0.7


(freedemons) #12

升级到最新的SDK都直报一堆错误了,jpush-hbuilder-demo这个示例是不是不适合升级sdk啊,能否加个QQ帮我远程看一下?


(HuminiOS) #13

QQ: 380108184


(Greta) #14

我遇到了一样的问题,SDK是最新的,demo前台可以收到通知,自己程序前台收不到通知,请问一下最后怎么解决了


#15

1、是否是iOS10以上的系统


(Greta) #16

是10.0以上的系统,实现设置alert


(Greta) #18

Message ID:36028797289495886 registrationID:1517bfd3f7c394113af 可以帮忙看一下为什么前台收不到推送吗


#20

1、推送内容上没有什么问题,是通知,且写了通知内容

2、在这种情况下,用我们的 demo 测试是必然会收到消息并在前台展示的。

3、所以请你仔细的检查你对前台实现通知展示的代码实现,参考 demo 的代码

// iOS 10 Support
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center  willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler {
  // Required
  NSDictionary * userInfo = notification.request.content.userInfo;
  if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
    [JPUSHService handleRemoteNotification:userInfo];
  }
  else {
     // 本地通知
  }
  completionHandler(UNNotificationPresentationOptionAlert); // 需要执行这个方法,选择是否提醒用户,有Badge、Sound、Alert三种类型可以选择设置
}


(Greta) #21

我把代码复制过去,没有进行其它的修改,还是在前台还是收不到通知,是还需要其它的设置吗?:sweat:


#22

你要不将APP卸载,手机关机,重启,然后重装APP再试下。


(Greta) #24

试过了,还是收不到:sweat:


#25

那我就不知道该咋办了,正常情况下是可以展示的,这个展示是iOS 系统 自动展示的,与 SDK 是无关的。你可以在你这个手机上安装我们的 demo 测试一下。

或在其他的iOS 10 以上手机上安装你的项目试一下,是否是该手机系统的bug