Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Android™ Development

Reply
Contributor
Posts: 18
Registered: ‎03-14-2013
My Device: Z10
My Carrier: NA
Accepted Solution

Not receiving push notification on device

[ Edited ]

Hi,

 

I followed all the steps as per http://developer.blackberry.com/android/documentation/signing_applications_1722776_11.html and https://developer.blackberry.com/android/apisupport/creating_push-enabled_android_apps.html to installed an existing Android application on BB 10 device with push notification support.

I was able to install the app on device and app was able to register the device pin to our push server.

 

Now I am trying to send a push notification to the app as per http://docs.blackberry.com/en/developers/deliverables/25167/Overview_1259222_11.jsp and I get a proper response as:

 

<!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP 2.1//EN" "http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd">
<pap>
<push-response push-id="pushID:102894418****" sender-address="http://cpXXXX.pushapi.eval.blackberry.com/mss/PD_pushRequest" sender-name="RIM Push-Data Service" reply-time="2013-03-14T01:22:45Z">
<response-result code="1001" desc="The request has been accepted for processing."/>
</push-response>
</pap>

 

But I don't get notification on phone.

 

Can you please help how to proceed further to debug? Note the same notification payload when sent via GCM is received on a Android device having same app.

Contributor
Posts: 18
Registered: ‎03-14-2013
My Device: Z10
My Carrier: NA

Re: Not receiving push notification on device

I also verified that the device is suucessfully registering to BB server for push notification as I can see the device status via:

 

request:

<?xml version="1.0"?>
<!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP 2.1//EN"
"http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd">
<bpds version="1.0">
<subscriptionquery-message pushservice-id="XXXX-*******************************">
<status status-value="active"/>
</subscriptionquery-message>
</bpds>

 

response:

<bpds version="1.0">
<subscriptionquery-response pushservice-id="XXXX-*******************************">
<subscriptionquery-result event-time="2013-03-18T17:48:45Z" code="21000" desc="The request succeeded"/>
<subscriptionquery-detail status="active" event-time="2013-03-18T17:41:01Z">
<address address-value="********"/>
</subscriptionquery-detail>
</subscriptionquery-response>
</bpds>

 

And when uninstalled, it returns no device active.

 

Please help on how to debug further.

Contributor
Posts: 18
Registered: ‎03-14-2013
My Device: Z10
My Carrier: NA

Re: Not receiving push notification on device

Now I am in a state where I can confirm that the notification was received on the device based on ADB output from device. But the notification does not appear on device may be due to below error I am seeing in logs:

 

Any help with this?

 

D/ShrimpController(14897352): res:getMsg

E/ShrimpController(14897352): Expecting push message to contain JSON data

D/QNXShrimpClient(14897352): onMessage() for package: com.ebay.mobile

D/ShrimpController(14897352): ack() Sending: msg::ack

D/ShrimpController(14897352): pushId::XXX-***********************

I/PushMessageReceiver(21299202): onReceive: action=com.google.android.c2dm.intent.RECEIVE

I/PushService(21299202): onHandleIntent: action=3, intent data=Bundle[{push_action=3, x-rim-deviceid=*********, Content-Length=240, OST / HTTP/1.1=POST / HTTP/1.1, <notification data here>, X-RIM-PUSH-SERVICE-ID=XXXX-**************************, Connection=close, Content-Type=application/x-www-form-urlencoded}]

V/GCMBroadcastReceiver(21299202): onReceive: com.google.android.c2dm.intent.RECEIVE

V/GCMBroadcastReceiver(21299202): GCM IntentService class: com.ebay.mobile.GCMIntentService

V/GCMBaseIntentService(21299202): Acquiring wakelock

E/BroadcastReceiver(21299202): BroadcastReceiver trying to return result during a non-ordered broadcast

E/BroadcastReceiver(21299202): java.lang.RuntimeException: BroadcastReceiver trying to return result during a non-ordered broadcast

E/BroadcastReceiver(21299202):  at android.content.BroadcastReceiver.checkSynchronousHint(BroadcastReceiver.java:451)

E/BroadcastReceiver(21299202):  at android.content.BroadcastReceiver.setResult(BroadcastReceiver.java:343)

E/BroadcastReceiver(21299202):  at com.google.android.gcm.GCMBroadcastReceiver.onReceive(GCMBroadcastReceiver.java:47)

E/BroadcastReceiver(21299202):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:1798)

E/BroadcastReceiver(21299202):  at android.app.ActivityThread.access$2400(ActivityThread.java:117)

E/BroadcastReceiver(21299202):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:981)

E/BroadcastReceiver(21299202):  at android.os.Handler.dispatchMessage(Handler.java:99)

E/BroadcastReceiver(21299202):  at android.os.Looper.loop(Looper.java:123)

E/BroadcastReceiver(21299202):  at android.app.ActivityThread.main(ActivityThread.java:3687)

E/BroadcastReceiver(21299202):  at java.lang.reflect.Method.invokeNative(Native Method)

E/BroadcastReceiver(21299202):  at java.lang.reflect.Method.invoke(Method.java:507)

E/BroadcastReceiver(21299202):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)

E/BroadcastReceiver(21299202):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)

E/BroadcastReceiver(21299202):  at dalvik.system.NativeStart.main(Native Method)

D/PushService(21299202): processNotification: No user specified in notification, exiting

V/GCMBaseIntentService(21299202): Releasing wakelock

Contributor
Posts: 18
Registered: ‎03-14-2013
My Device: Z10
My Carrier: NA

Re: Not receiving push notification on device

Just to add a note here, to an earlier issue I was facing and the solution to that:

Issue: getting "android/android.cfg: unknown asset" when adding android.cfg manually via a zip uitility into the bar file

 

Solution:

Option 1: Add below manual entry to the bar manifest file. (probably not best option to do)

Archive-Asset-Name: android/android.cfg"

 

Option 2: If you have an APK named {something}.APK (e.g., ‘foo.APK’), then running apk2bar with the ‘-m -ma’ arguments will automatically look for ‘foo.MF’ and ‘foo.CFG’ in the same folder.  If they exist, they will be packaged as part of the BAR.  HOWEVER, apk2bar also automatically renames the CFG file in the process - instead of ‘foo.CFG’, it appears in the BAR as ‘android\android.cfg’. When the resulting BAR is signed, the android.cfg file will get signed automatically.

 

Option 3: Put the <projectName>.cfg file under the root of the Android project and then create apk and then repackage it as bar and you will find ‘android\android.cfg’ file present in bar file.

 

For me since I started with an existing apk file (so just support existing apk on the BB device without any code modification), I prefered option #2.

Contributor
Posts: 18
Registered: ‎03-14-2013
My Device: Z10
My Carrier: NA

Re: Not receiving push notification on device

Progress on the notification issue:

It seems there are two issues here:

1. The payload sent to real c2dm/gcm device is not working directly on BB device and requires cutomization on the app side to make it work with existing payload which works with c2dm/GCM notificatoin.

2. The RiuntimeException is a known issue from BlackBerry side and will be fixed next version and it is not effecting notification.

Contributor
Posts: 18
Registered: ‎03-14-2013
My Device: Z10
My Carrier: NA

Re: Not receiving push notification on device

when we print same logs from Android app working with GCM, it shows the intent's bundle populated differently than the same notification payload when sent to Android runtime on BB:

 

Existing Android app with c2dm or GCM:

 

I/PushService(29712): onHandleIntent: action=3, intent data=Bundle[{clientid=appname, itm=21654314354, push_action=3, title=Test Notification!!, collapse_key=test, sound=test.caf, evt=test, device=testdevice, from=******, usr=test}]

 

Same Android app for BB android runtime:

 

I/PushService(21299202): onHandleIntent: action=3, intent data=Bundle[{push_action=3, x-rim-deviceid=2ab00c93, Content-Length=192, OST / HTTP/1.1=POST / HTTP/1.1, data={"clientid":"appname","itm":"21654314354","title":"Test Notification!!","usr":test","evt":"test"}, X-RIM-PUSH-SERVICE-ID=******, Connection=close, Content-Type=application/json}]

 

You can notice that, for the original GCM app the intent's bundle receives the data under the JSON 'data' member while for the BB Android runtime, entire HTTP header and body has been provided to the service in the intent's bundle, with the 'data' object being interpreted as just another opaque field. Which is why I guess app is not able to read the notification. Not sure then how the same notification payload can work with BB device?

 

Looks like to make it work we need to tweak the payload on server side and app side code to understand the new format form the intent Bundle. Like removing "data" from the json and sending it directly.

Contributor
Posts: 18
Registered: ‎03-14-2013
My Device: Z10
My Carrier: NA

Re: Not receiving push notification on device

Some info regarding sending test notification quickly via some XML tools.

 

You can use a XML post tool like soapui etc and use the following format to test it out:

URL: https://cpXXX.pushapi.eval.blackberry.com/mss/PD_pushRequest 

replace XXXX with CPID as per BB registration email

 

Headers:

Authorization: Basic <based on document>

Content-Type: multipart/related; type=\"application/xml\"; boundary=<boundary>

 

Request:

--<boundary>

Content-Type: application/xml; charset=UTF-8

<?xml version="1.0"?>

<!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP 1.0//EN" "http://www.openmobilealliance.org/tech/DTD/pap_1.0.dtd">

<pap>

<push-message push-id="pushID:999999999" 

                source-reference="XXXX-xxxxxxxxxxxxxxxxxxxxxxxx" <!-- your appid as per BB registration email>

        deliver-before-timestamp="2020-12-31T23:59:59Z">

                <address address-value=<device pin>/>

<quality-of-service delivery-method="unconfirmed"/> <!-- or "confirmed" >

</push-message>

</pap>

--asdlfkjiurwghaslkfjsadkfaksdjff

 

{

     "key":"value",

      "key2":"value2"

}

--asdlfkjiurwghaslkfjsadkfaksdjff--

Contributor
Posts: 18
Registered: ‎03-14-2013
My Device: Z10
My Carrier: NA

Re: Not receiving push notification on device

Some info on how to check if the device is active with BlackBerry serevr to receive push notification:

 

Subscription query to BB server:

URL: https://cpXXXX.pushapi.eval.blackberry.com/mss/PD_cpSubQuery

 

Header:

Authorization: Basic <based on document>

Content-Type: application/xml

 

Request:

<!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP 2.1//EN" "http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd">

<bpds version="1.0">

   <subscriptionquery-message pushservice-id="XXXX-xxxxxxxxxxxxxxxxxxxxxxxx" <!-- your appid as per BB registration email>

      <status status-value="active"/>

   </subscriptionquery-message>

</bpds>

 

Response:

 

<bpds version="1.0">

   <subscriptionquery-response pushservice-id="XXXX-xxxxxxxxxxxxxxxxxxxx">

      <subscriptionquery-result event-time="2013-03-20T16:27:58Z" code="21000" desc="The request succeeded"/>

      <subscriptionquery-detail status="active" event-time="2013-03-19T20:10:50Z">

         <address address-value=<device pin>/>

      </subscriptionquery-detail>

   </subscriptionquery-response>

</bpds>

 

More details: http://docs.blackberry.com/en/developers/deliverables/25167/Subscription_query_1461311_11.jsp

Contributor
Posts: 10
Registered: ‎03-15-2013
My Device: BlackBerry 10 Dev Alpha B
My Carrier: T-Mobile

Re: Not receiving push notification on device

Hi... vmurarka,

Thank you so much for the information. Those are so helpful. Have you found the solution for the below exception?? I also have got it every time when registered and got new messages, but if I run the same APK to real Android device, it does not happen.

Thanks in advance Smiley Happy

K.

==

03-21 16:19:58.710: E/BroadcastReceiver(244240593): BroadcastReceiver trying to return result during a non-ordered broadcast
03-21 16:19:58.710: E/BroadcastReceiver(244240593): java.lang.RuntimeException: BroadcastReceiver trying to return result during a non-ordered broadcast
03-21 16:19:58.710: E/BroadcastReceiver(244240593): at android.content.BroadcastReceiver.checkSynchronousHint(BroadcastReceiver.java:451)
03-21 16:19:58.710: E/BroadcastReceiver(244240593): at android.content.BroadcastReceiver.setResult(BroadcastReceiver.java:343)
03-21 16:19:58.710: E/BroadcastReceiver(244240593): at com.google.android.gcm.GCMBroadcastReceiver.onReceive(GCMBroadcastReceiver.java:56)
03-21 16:19:58.710: E/BroadcastReceiver(244240593): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1798)
03-21 16:19:58.710: E/BroadcastReceiver(244240593): at android.app.ActivityThread.access$2400(ActivityThread.java:117)
03-21 16:19:58.710: E/BroadcastReceiver(244240593): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:981)
03-21 16:19:58.710: E/BroadcastReceiver(244240593): at android.os.Handler.dispatchMessage(Handler.java:99)
03-21 16:19:58.710: E/BroadcastReceiver(244240593): at android.os.Looper.loop(Looper.java:123)
03-21 16:19:58.710: E/BroadcastReceiver(244240593): at android.app.ActivityThread.main(ActivityThread.java:3687)
03-21 16:19:58.710: E/BroadcastReceiver(244240593): at java.lang.reflect.Method.invokeNative(Native Method)
03-21 16:19:58.710: E/BroadcastReceiver(244240593): at java.lang.reflect.Method.invoke(Method.java:507)
03-21 16:19:58.710: E/BroadcastReceiver(244240593): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
03-21 16:19:58.710: E/BroadcastReceiver(244240593): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
03-21 16:19:58.710: E/BroadcastReceiver(244240593): at dalvik.system.NativeStart.main(Native Method)
Highlighted
Contributor
Posts: 18
Registered: ‎03-14-2013
My Device: Z10
My Carrier: NA

Re: Not receiving push notification on device

regarding this error, as I mentioned earlier:
The RiuntimeException is a known issue from BlackBerry side and is fixed next version and will not effecting notification.