Quantcast

Get the deviceToken - Android

classic Classic list List threaded Threaded
4 messages Options
hh
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Get the deviceToken - Android

hh
Hey All,

how can we retrieve the deviceToken in Android?

It seems impossible to be done, and I need it to unregister the device (API call needs the deviceToken).

Thanks for your help,

Kr,

Henry
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Aerogear-users] Get the deviceToken - Android

Daniel Passos

On Mon, Apr 18, 2016 at 7:05 PM, hh <[hidden email]> wrote:
Hey All,

how can we retrieve the deviceToken in Android?

It seems impossible to be done, and I need it to unregister the device (API
call needs the deviceToken).

Thanks for your help,

Kr,

Henry



--
View this message in context: http://aerogear-users.1116366.n5.nabble.com/Get-the-deviceToken-Android-tp619.html
Sent from the aerogear-users mailing list archive at Nabble.com.
_______________________________________________
Aerogear-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-users



--
-- Passos

_______________________________________________
Aerogear-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-users
hh
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Aerogear-users] Get the deviceToken - Android

hh
Hi Daniel,

Thanks for your reply.

I knew about the "unregister" method but it didn't do his job perfectly, as sometimes it wasn't unregistered and I had the following block & error which where throwed.

 if ((deviceToken == null) || (deviceToken.trim().equals(""))) {
                        throw new IllegalStateException(DEVICE_ALREADY_UNREGISTERED);
 }

But my device was still registered, so I don't really understand why this error was throwed.

Probably, the deviceToken is null, as for the register method, we have the following:

 if (instanceId == null) {
                        instanceId = instanceIdProvider.get(context);
                    }
                    String token = instanceId.getToken(senderId,
                                                    GoogleCloudMessaging.INSTANCE_ID_SCOPE);
                   
                    deviceToken = token;



while for the unregister method there is nothing, so I don't see how the deviceToken could not be null?

Thanks,

Henry
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Aerogear-users] Get the deviceToken - Android

Summers Pittman
Are you using the same instance of the registrar to register and unregister?

On Tue, Apr 19, 2016 at 9:48 AM, hh <[hidden email]> wrote:
Hi Daniel,

Thanks for your reply.

I knew about the "unregister" method but it didn't do his job perfectly, as
sometimes it wasn't unregistered and I had the following block & error which
where throwed.

 if ((deviceToken == null) || (deviceToken.trim().equals(""))) {
                        throw new
IllegalStateException(DEVICE_ALREADY_UNREGISTERED);
 }

But my device was still registered, so I don't really understand why this
error was throwed.

Probably, the deviceToken is null, as for the register method, we have the
following:

 if (instanceId == null) {
                        instanceId = instanceIdProvider.get(context);
                    }
                    String token = instanceId.getToken(senderId,

GoogleCloudMessaging.INSTANCE_ID_SCOPE);

                    deviceToken = token;



while for the unregister method there is nothing, so I don't see how the
deviceToken could not be null?

Thanks,

Henry



--
View this message in context: http://aerogear-users.1116366.n5.nabble.com/Get-the-deviceToken-Android-tp619p621.html
Sent from the aerogear-users mailing list archive at Nabble.com.
_______________________________________________
Aerogear-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-users


_______________________________________________
Aerogear-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-users
Loading...