3

I'm creating an app using IBM MobileFirst Platform Foundation 7.0 that has push notifications support. At this point, iOS devices can successfully receive notifications while the app isn't running. 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:

{
  "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.
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
JM Huret
  • 361
  • 3
  • 5
  • trailing , after target, and there is no apn key. – some_id Aug 08 '15 at 03:32
  • The documentation also lists "actionKey" not "isActionKey": http://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.0.0/com.ibm.worklight.apiref.doc/html/refjavascript-server/html/WL.Server.html%23sendMessage – Idan Adar Aug 08 '15 at 03:35
  • What does the code look like that processes the push notification payload? [Could you set a breakpoint on all exceptions](https://developer.apple.com/library/ios/recipes/xcode_help-breakpoint_navigator/articles/adding_an_exception_breakpoint.html#//apple_ref/doc/uid/TP40010433-CH1-SW1)? That way, when the exception gets thrown, you'll know exactly which line it came from. – Michael Dautermann Aug 08 '15 at 04:51
  • I am still getting the same error. I linted the json and now I have the following: `{ "message": { "alert": "Test message" }, "settings": { "apns": { "actionKey": "Ok", "payload": "" } }, "target": { "consumerIds": [], "deviceIds": [], "platforms": [ "A" ], "tagNames": [] } }` I'm not sure what you mean by 'there is no apn key' ... I have my apns certificate, and .p12 file generated. Is there another field I need to be specifying in the json? – JM Huret Aug 08 '15 at 21:21
  • 1
    Wow, I was able to fix it by correcting the payload. Even though many of the examples I have seen show that you can use an empty string, it actually needs to be a javascript object, or not be present at all, or it will crash the app. I now receive notification while the app is running without it crashing. @IdanAdar, do you know how I can get some type of in app response to this message, like an alert? I can see in my console that it receives the message, but nothing happens by default. Do I need to define the correct method in the app delegate or something? Thanks for your help! – JM Huret Aug 08 '15 at 21:33
  • What are you trying to do? display the message or handle the payload? Did you look at how it is implemented in the Getting Started example? You also need to mention if this is Hybrid or Native... – Idan Adar Aug 09 '15 at 04:02
  • It's hybrid. I just need to check the payload and act on it with a notice to the user. I'll try using WL.Client.Push.onMessage. – JM Huret Aug 10 '15 at 12:01
  • JM Huret , Can u please give me the payload format for MFP , thakyou – MANCHIKANTI KRISHNAKISHORE Sep 09 '16 at 07:59
  • Sorry Manchikanti, I do not have access to this payload anymore. – JM Huret Sep 12 '16 at 15:02

1 Answers1

0

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

or 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. If using Tag/Broadcast notifications,this will be WL.Client.Push.onMessage

Vivin K
  • 2,681
  • 1
  • 11
  • 14