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

BlackBerry Push Development

Reply
Contributor
iheartBlckBry
Posts: 21
Registered: ‎03-18-2014
My Device: BB10
Accepted Solution

push notifications for Android ports

I've ported a working Android app with working Android push notifications to BB10.  I've followed the creating_push-enabled_android_apps guide and I'm still not getting any notifications on my BB10 device.  Just in case I'm missing something obvious, can someone please just answer a simple simple question for me? 

 

When I get this finally working, will it actually be a Google push (either C2DM or GCM) that initiates the notifications on my BB10 device, or do I need to rewrite everything for Blackberry Push?  I'd prefer to keep using Google push and it appears that might be a possibility, but I'm skeptical that C2DM would work on a Blackberry device since it requires a Google account and Google Play in order to work (at least that was listed as a requirement back when I first learned about C2DM). 

 

 

Please use plain text.
Retired
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: push notifications for Android ports

You would need to push through the BlackBerry servers, the Google servers will not be able to deliver those messages to the BlackBerry devices.

 

If the above does not resolve the issue could you please provide some details on what you have done and what is being tested so far?

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.
Contributor
iheartBlckBry
Posts: 21
Registered: ‎03-18-2014
My Device: BB10

Re: push notifications for Android ports

[ Edited ]

Here are the continuing points of confusion:

 

In the "Creating Push-Enabled Android Apps" tutorial it says to do a step and then at the end says "and will allow your Android app to work without changing any code or compiling again. "  Nowhere does it talk about doing all of the coding for changing the registration of the device (which in Android registers to the GCM/C2DM mothership to get a Registration ID).  Is there boilerplate code for this?  Do I need to add some code in Eclipse that pulls the PIN from the device?  Wouldn't that require adding a Blackberry library of some sort to the project?  

 

And then the other problem is that since I assume that I'm supposed to be writing code to register with Blackberry (on a device level) for push notifications from the Blackberry Push Service, none of the sample code is in Java or geared towards developers working in Eclipse.  I found some sample code in C++ and I believe JavaScript, but how is that going to help an Android developer working in Eclipse do what needs to be done?

 

 

Please use plain text.
Retired
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: push notifications for Android ports

There are no device-side code changes required, the android.cfg file will tell the runtime to register your app against the BlackBerry servers as opposed to the GCM/C2DM servers.

 

As for the server-side, we offer a full Java SDK for sending push messages to BlackBerry devices here:

https://developer.blackberry.com/devzone/develop/platform_services/push_service_sdk.html

 

In its simplest form the server code sends an XML formatted HTTP POST to the BlackBerry servers. The following doc provides examples of the PAP templates used by the service if you'd like to write your own implementation:

http://docs.blackberry.com/en/developers/deliverables/25167/

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.
Contributor
iheartBlckBry
Posts: 21
Registered: ‎03-18-2014
My Device: BB10

Re: push notifications for Android ports

The device needs to tell our notification server its unique ID so that when a push notification needs to be sent, the server knows who to send it to.  In Google Push, the device registers with Google, gets a unique ID back, and we have the device upload this value to our servers so we can identify it later for Push purposes.

 

Where in our Android code does this piece happen?  The documentation mentions placing a prefix ("bb-" for example) in front of the registration ID, but where does the Android code get this registration ID?  Does the device still register with Google Servers to get a reg ID even though it's a Blackberry device?  The documentation mentions that a particular flavor of GCM works, but we're still using C2DM.

Please use plain text.
Retired
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: push notifications for Android ports

The device does not talk to the Google servers at all. The registration ID is handled within the client, your app, the same way when run on BlackBerry.

 

The 'bb-' prefix is specified in the android.cfg file, this value can really be set to whatever you like. The registration ID will be passed to your app with the aforementioned value prefixed. Your server can determine whether it is an Android or BlackBerry registration by checking for the prefix value, then it can determine whether to push through GCM or the BlackBerry servers accordingly.

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.
Contributor
iheartBlckBry
Posts: 21
Registered: ‎03-18-2014
My Device: BB10

Re: push notifications for Android ports

There seems to be a conflict between "no code needs to be changed in the Android project" and "the app now uses a Blackberry ID instead of a Google ID".

 

How do I get the Blackberry ID?

Without changing my code how am I supposed to upload this ID to my server?

Why is a prefix needed if it's an 8 digit Blackberry ID which is clearly different from the very long Google registration ID?

 

 

Please use plain text.
Retired
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: push notifications for Android ports

There's no conflict, but perhaps I'm not being clear. It also has *nothing* to do with BBID, not sure where that even came in.

 

You retrieve the BlackBerry registration ID, which is a PIN, as opposed to the Google registration ID, whatever that is. 

 

The prefix is meant to make the differentiation easier, the address used by  BlackBerry may not always be the PIN (not saying there are plans to change it, but it could perceivably happen).

 

The ID would be uploaded to your server the same way the Google ID would be, your server could use the prefix to determine what kind of device is being registered.

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.
Contributor
iheartBlckBry
Posts: 21
Registered: ‎03-18-2014
My Device: BB10

Re: push notifications for Android ports

I think I'm getting closer and I appreciate your help so much.

 

Where does my Android code get the BlackBerry registration ID?  Wouldn't that require a code change?

 

 

Please use plain text.
Retired
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: push notifications for Android ports

How do you get the registration ID on an Android device? I believe it's the same

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.