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

Re: push notifications for Android ports

For Google Push the device sends a registration request to the Google Server and a very long registration ID is returned.  This ID is mentioned in the Blackberry document on how to port push-enabled Android apps.

 

This registration ID needs to be saved to our servers so we know who to ask the Apple/Google/Blackberry push services to push to.

 

Since the ported app will not talk to Google Servers, the step where the app gets the unique ID of the device that it's on so that this ID can be uploaded to our servers for future Push information seems like it needs to be changed in the code.

Retired
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: push notifications for Android ports

The app will retrieve a similar ID from the BlackBerry servers, the app itself will not be able to know which server it is working with.

 

Does your client app retrieve the registration ID when run on Android devices? If so the same code should retrieve the BlackBerry device ID (token) when run on a BlackBerry device.

 

This post shows the code:

http://supportforums.blackberry.com/t5/BlackBerry-Push-Development/How-to-get-the-Push-Pin-on-Androi...

 

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

Re: push notifications for Android ports

Yes, my Android client app retrieves a registration ID when using Google Push.  It asks for the ID from the Google servers.  Without a code change, it will continue to request an ID from Google servers.  I debugged it yesterday and not surprisingly this ID was null on a Blackberry device (because it was asking Google for an ID for a Blackberry device).

 

In the post you referenced, "The device PIN is returned as a token in the GCM intent listener when registration has been completed. It can be retrieved from the intent using the following code:
final String token = intent.getStringExtra("registration_id");" implies that the Blackberry device still asks Google for a registration ID.  A GCM intent listener talks to Google and Google returns the ID.

 

To review:

An Android app using Google push does the following things:

1.  Fires up for the first time.

2. Asks Google C2DM/GCM for a registration ID.

3.  Receives the registration ID so it can be uploaded to our servers for push reference.

 

When porting an Android app to Blackberry, you're saying that I don't need to do step 2 and instead need to get a Blackberry ID of some sort (the 8 digit one?).  But that would require a code change, which I thought wasn't necessary. 

Retired
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: push notifications for Android ports

The BlackBerry Runtime for Android apps takes the call to the Google servers and replaces it with a call to the BlackBerry servers to receive a similar registration ID. 

 

Android device:

App ==> Runtime ==> Google Servers (registration ID gathered)

Google Servers ==> Runtime ==> App

 

BlackBerry device running *same* app but with an android.cfg file added and proper permissions for push:

App ==> Runtime ==> BlackBerry servers (registration ID gathered)

BlackBerry servers ==> Runtime ==> App

 

The app has no idea what back-end server it is talking to, this is handled by the lib/runtime. 

 

 

If a value is null it does not mean that the call to the Google Servers did not work, as mentioned above the app will not talk to the Google Servers for registration. It could be an issue with how the app is configured, but the concept that Google Servers are not involved and that the runtime handles the redirect to the BlackBerry servers needs to be understood before we can move forward with any sort of troubleshooting.

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

Re: push notifications for Android ports

[ Edited ]

I now understand that Google servers no longer provide registration IDs. I'm not grasping the piece where the old code (which used to ask Google for the info) now automatically asks BlackBerry instead. Is it An actual network call or does it just query the service internally? Should I expect to see a BlackBerry ID in the point of my code where it previously returned a Google ID?

Retired
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: push notifications for Android ports

The actual code that makes server calls is abstracted, it's not something you, as a developer, actually code.

 

You should expect to receive a BlackBerry token/device address when using the chunk of code I referenced earlier.

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

Re: push notifications for Android ports

I'm finally getting a chance to implement this after paternity leave and so far so bad.

 

I've followed the instructions exactly, but when I debug on the device via Eclipse, the value of "token" at the line below is null.

 

final String token = intent.getStringExtra("registration_id");

 

Anything else I could be missing?

 

 

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

Re: push notifications for Android ports

I am seeing "INVALID_SENDER" in the same area of code, though.  I think I've seen this in my research on this so I will search for that while I wait to hear back from a badly-needed helpful person.  Thanks!

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

Re: push notifications for Android ports

I successfully just had it work!  Not sure what I did prior to it working, but I should be good to go unless I hit a wall again.  Thanks for all the help!