0
votes

I'm having some issues getting push notifications to work on Android. I have added a pushSender to the android section of the application-descriptor.xml with the key that was generated (I've removed our key values).

<android version="1.0.5">
    <worklightSettings include="true"/>
    <pushSender key="our key" senderId="our sender"/>
    <security>
        <encryptWebResources enabled="true"/>
        <testWebResourcesChecksum enabled="true" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3"/>
        <publicSigningKey>our key</publicSigningKey>
    </security>
</android>

Every time I start the app, I get the message "Failed registering for push notifications. The application will not be able to receive notifications.

I thought for a little while that it may be because I was testing on our internal network and it needed access to the outside world, but even when it could get to the world, I still received the message. I've tried adding the securityTest parameter to the android tag, but it did not make any difference.

In the authenticationconfig.xml file, I've added a mobile security test to the security tests section:

    <mobileSecurityTest name="PushApp-securityTest">
        <testDeviceId provisioningType="none"/>
        <testUser realm="PushAppRealm"/>
    </mobileSecurityTest>

I have the realm set up like this:

    <realm name="PushAppRealm" loginModule="PushAppLoginModule">
        <className>com.worklight.core.auth.ext.PersistentCookieAuthenticator</className>
    </realm>    

And the login module is like this:

    <loginModule name="PushAppLoginModule">
        <className>com.worklight.core.auth.ext.NonValidatingLoginModule</className>
    </loginModule>  

I'm really lost as to why it is failing to register. We're running Worklight 5.0.6.2.

1
See my setup given in the following question. While it was tested with 6.2, it is the same for 5.0.6.2: stackoverflow.com/questions/24818382/…Idan Adar
@idan-adar For this to work, do you have to use some sort of actual login (i.e. entering a user id/password)? We want to allow the app to receive push notifications without them logging in, and I thought that the PersistenCookieAuthenticator would allow that. I've been through the process of setting up the GCM key. I did not realize we needed to use a browser key and not a server key, but even with the browser key, I still get the failed to register message.Digital Wolf
You could explicitly register the device, but a good citizen(app) would check with the user first. ...Idan Adar
We're not planning to just blindly set up a user for push notifications. We're going to check to see if they are registered and give them a pop-up to ask if they'd like to receive the notifications. Could there be an issue with the key I'm entering? I was under the impression that the PersistentCookieAuthenticator would create a device type ID to be the "user" to register, so that an explicit logon would not be required. I just wonder about the key, as if I comment out the pushSender from the app descriptor but do not remove any of the code for push notifications, the app starts fine.Digital Wolf
Are you using the right value for the senderID ? I was receiving the same error message and just found that I was using the "Project ID" instead of the "Project Number". You need to use the "Project Number" in the senderID field.Leandro David

1 Answers

0
votes

From the comments:

For this to work, do you have to use some sort of actual login (i.e. entering a user id/password)?

If you are using Event source-based notifications, then yes - a login is required.
You can read an explanation here: receive GCM push without WLClient::connect()

It sounds like for this particular need of yours, you could use either Broadcast or Tag-based notifications. You can read more about these types in this user documentation topic. The topic also provides example implementations to follow-up with.