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™ Runtime Development

Reply
New Contributor
Posts: 8
Registered: ‎06-16-2014
My Device: Q5
My Carrier: Wind

Android GCM call fails on Blackberry Q5

I have a Q5 device with 10.2.1.2941 OS release. I'm trying to port my Android application with GCM on to blackberry device. Where I have followed all the instructions from the following link

 

http://developer.blackberry.com/android/apisupport/creating_push-enabled_android_apps.html

 

I have created a new android.cfg file and added my ppurl and applicaion id, added the file into the BAR package before signing it to deploy.

 

When I run my app on the blackberry device,  it is failing at GCMRegistrar.register call.

 

Am I missing anything here?

New Contributor
Posts: 8
Registered: ‎06-16-2014
My Device: Q5
My Carrier: Wind

Re: Android GCM call fails on Blackberry Q5

The documentation tells me to create an "android.cfg" file:

http://developer.blackberry.com/android/apisupport/creating_push-enabled_android_apps.html

 

I've learned from these froums that I need to create a .cfg file with the project name and place it under the root directory:

https://supportforums.blackberry.com/t5/Android-Runtime-Development/Creating-Push-Enabled-Android-Ap...

 

I did that, then used the blackberry packaging tool to generate the BAR file:

blackberry-apkpackager -gui

 

This time the command line tool renamed the cfg file to android.cfg for me and made the following entry in the manifest file:

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

 

It's unclear if this has changed anything. When I run my app, still it is failing at GCMRegistrar.register call.

 

I'd love to hear some suggestions on this.

 

New Contributor
Posts: 8
Registered: ‎06-16-2014
My Device: Q5
My Carrier: Wind

Re: Android GCM call fails on Blackberry Q5

Created a basic "Hello World" type app to test it out.

 

I'm printing out the results of all the GCM related calls. Now I'm getting "INVALID_SENDER".

 

I'm guessing this has something to do with what Google refers to as the "Project ID" or "Sender ID". In my project I've left this unchanged from what I was assigned by Google as I haven't read any instructions from Blackberry to change it. I've tried passing an empty string. It still returns INVALID_SENDER. (On a real Android it returns INVALID_PARAMETERS in that case)

 

Here's my android.cfg:

 

<?xml version="1.0" encoding="utf-8"?>
<android>
   <push>
      <appid>4733-h65235B8D6909y6nnXXXXXXXXXXXXXXXXXX</appid>
      <ppgurl>https://cp4733.pushapi.eval.blackberry.com</ppgurl>
      <tokenprefix>bb</tokenprefix>
   </push>
</android>

 

Here's the code I'm using to test:

 

 super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView logView = (TextView)findViewById(R.id.logger);
        GCMRegistrar.checkDevice(this);
        GCMRegistrar.checkManifest(this);
        String regId = GCMRegistrar.getRegistrationId(this);
        if (regId.equals("")) {
            logView.setText("Calling GCMRegistrar.register");
            GCMRegistrar.register(this, GcmIntentService.GCM_SENDER_ID);
            logView.setText("After GCMRegistrar.register method call, regid = "+GcmIntentService.regid+", isRegisterd = "+GCMRegistrar.isRegistered(getApplicationContext()));
        } else {
            logView.setText("Already registered"+", regId = "+regId);
        }

 

Can anyone shed any light on this problem?

 

I see a lot of similar questions about GCM on Blackberry and nobody seems to have definitive answers. Does anyone who works for Blackberry read this forum?

 

New Contributor
Posts: 8
Registered: ‎06-16-2014
My Device: Q5
My Carrier: Wind

Re: Android GCM call fails on Blackberry Q5

I think I have found the problem. SSL is not supported from the client side!

New Contributor
Posts: 8
Registered: ‎06-16-2014
My Device: Q5
My Carrier: Wind

Re: Android GCM call fails on Blackberry Q5

Great, so now I can successfully make the registration call, but it only works after the app is restarted... argh.

BlackBerry Development Advisor
Posts: 846
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: Android GCM call fails on Blackberry Q5

The app will need to be started at least once to register with the system for the pushes. Are you finding that it has to run more than that for them to be received? 

Tim Windsor
Open Source Technical Lead
New Contributor
Posts: 8
Registered: ‎06-16-2014
My Device: Q5
My Carrier: Wind

Re: Android GCM call fails on Blackberry Q5


twindsor wrote:

The app will need to be started at least once to register with the system for the pushes. Are you finding that it has to run more than that for them to be received? 


Thank you for replying!

 

It works the first time now. Now I'm working on having my server send the push notification to the device.

BlackBerry Development Advisor
Posts: 846
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: Android GCM call fails on Blackberry Q5

Glad to hear it. I'm watching this thread if you have any other issues. Hopefully it goes smoothly now.
Tim Windsor
Open Source Technical Lead