简体   繁体   English

推送通知会导致应用崩溃

[英]push notification causes app to crash

I'm creating an app using IBM MobileFirst Platform Foundation 7.0 that has push notifications support. 我正在使用具有推送通知支持的IBM MobileFirst Platform Foundation 7.0创建应用程序。 At this point, iOS devices can successfully receive notifications while the app isn't running. 此时,iOS设备可以在应用程序未运行时成功接收通知。 However, if I touch the banner message from a notification, the app will launch and then immediately crash. 但是,如果我从通知中触摸横幅消息,应用程序将启动,然后立即崩溃。 Similarly, if the app is already running and a push notification arrives, the app will immediately crash. 同样,如果应用程序已在运行并且推送通知到达,则应用程序将立即崩溃。

What is strange is that I was not always seeing this behavior initially. 奇怪的是,我最初并不总是看到这种行为。 However, now it happens every time under the circumstances mentioned. 但是,现在每次都在所提到的情况下发生。

How can I correct this? 我怎么能纠正这个? Is there a patch I need to install? 我需要安装补丁吗? I have uninstalled/reinstalled the app with no success. 我已卸载/重新安装该应用程序但没有成功。

Here is the payload I'm sending through the Worklight REST API Send Message: 这是我通过Worklight REST API发送消息发送的有效负载:

{
  "message" : {
    "alert" : "Test message",
  },
  "settings" : {
    "apns" : {
      "badge" : 1,
      "iosActionKey" : "Ok",
      "payload" : "",
      "sound" : "song.mp3"
    }
  },
  "target" : {
    "consumerIds" : [],
    "deviceIds" : [ ],
    "platforms" : [ "A"],
    "tagNames" : [],
  },
}

Here is the error report from my device: 以下是我的设备的错误报告:

> apsd[93] <Error>: Property list invalid for format: 200 (property lists cannot contain objects of type 'CFNull')   [209] <Warning>:
> [DEBUG] [WL_PUSH] -[Push processRemotePushNotification:] in Push.m:426
> :: Push: didReceive Remote notification   [209] <Warning>: [FATAL]
> [WORKLIGHT] Uncaught Exception: *** -[__NSArrayI objectAtIndex:]:
> index 1 beyond bounds [0 .. 0]   [209] <Error>: *** Terminating app
> due to uncaught exception 'NSRangeException', reason: '***
>     -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'     *** First throw call stack:     (0x1863cc2d8 0x1980980e4 0x1862afb34
> 0x1002a5afc 0x1002a558c 0x1872c0180 0x18638412c 0x186383ddc
> 0x186381828 0x1862ad2d4 0x18fd036fc 0x18aeaaf40 0x1000ac0e0
> 0x198742a08)   ReportCrash[210] <Error>: task_set_exception_ports(B07,
> 400, D03, 0, 0) failed with error (4: (os/kern) invalid argument)  
> ReportCrash[210] <Notice>: ReportCrash acting against PID 209  
> ReportCrash[210] <Notice>: Formulating crash report for process [209] 
> com.apple.xpc.launchd[1]
> (UIKitApplication:com.companyname.appname.qa[0xc100][209]) <Notice>:
> Service exited due to signal: Abort trap: 6   ReportCrash[210]
> <Notice>: Saved report to
> /var/mobile/Library/Logs/CrashReporter/_2015-08-07-231518_.ips  
> SpringBoard[54] <Warning>: Application
> 'UIKitApplication:com.companyname.appname.qa[0xc100]' crashed.

If the payload received by the client is not in the right format, behaviour as observed is expected. 如果客户端接收的有效负载格式不正确,则预期会出现观察到的行为。 As a first step , ensure the payload is in the right format as noted in the links below- 作为第一步,确保有效载荷的格式正确,如下面的链接所示 -

WL.Server.sendMessage WL.Server.sendMessage

or REST API REST API

The client side handlers are already defined within the framework and you do not need to implement it on your own. 客户端处理程序已在框架中定义,您无需自己实现它。 To work on the payload,use the appropriate JS callback function at client side. 要处理有效负载,请在客户端使用适当的JS回调函数。 If using Tag/Broadcast notifications,this will be WL.Client.Push.onMessage 如果使用标记/广播通知, 则为WL.Client.Push.onMessage

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM