Issues unregistering from server

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Issues unregistering from server

alan10fm
Hi everybody.

I am making an android app using unified push server and Openshift.
I am using the code in the next link to register my devices
https://aerogear.org/docs/guides/aerogear-android/push/
the register works good and i can receive push notification.
My problem is when i want to unregister the device, when i register the device and i never close the app and i unregister the device it works but my issue is when i register my device and close the app, after relaunch the app when i try to unregister the device the app brokes because of a null pointer exception in this line
registrar.unregister(getApplicationContext(), new Callback<Void>()
because the registar object is null

I have made a lot of combinations to recover the registar object but anything works the server returns me a 404 code error.
In this link is my code:
https://stackoverflow.com/questions/31363464/unregister-devices-aerogear

I will appreciate any help with this.
--
Reply | Threaded
Open this post in threaded view
|

Re: [Aerogear-users] Issues unregistering from server

Summers Pittman
1) You should be creating the PushRegistrar object in a static block in your activity OR in the onCreate method of your Application (also make sure you have subclassed application and set that class to the name property of your application in your AndroidManifest.)

2) You need to also make sure that register() is called before unregister().  If Android kills your application you will need to call register to call unregister.  It is a bit counter intuitive but it keeps your registration state in sync with GCM so that you are properly unregistered.

3) Do you have a github we can take a look at with the project in it?  

On Fri, Jul 17, 2015 at 12:56 PM, alan10fm <[hidden email]> wrote:
Hi everybody.

I am making an android app using unified push server and Openshift.
I am using the code in the next link to register my devices
https://aerogear.org/docs/guides/aerogear-android/push/
the register works good and i can receive push notification.
My problem is when i want to unregister the device, when i register the
device and i never close the app and i unregister the device it works but my
issue is when i register my device and close the app, after relaunch the app
when i try to unregister the device the app brokes because of a null pointer
exception in this line
registrar.unregister(getApplicationContext(), new Callback<Void>()
because the registar object is null

I have made a lot of combinations to recover the registar object but
anything works the server returns me a 404 code error.
In this link is my code:
https://stackoverflow.com/questions/31363464/unregister-devices-aerogear

I will appreciate any help with this.
--




--
View this message in context: http://aerogear-users.1116366.n5.nabble.com/Issues-unregistering-from-server-tp140.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
Reply | Threaded
Open this post in threaded view
|

Re: [Aerogear-users] Issues unregistering from server

alan10fm
hi.
Thank you for the answer.
I had tried that before, call first the register method and then the unregister, and that works good, it is just that I thought that was not the best way to solve it, but it looks like it is.
So I think that solves my problem.
Thank you