how to trigger a gcm to send a push notification to android device(using java server) -
i new java server side development, have followed link [http://javapapers.com/android/google-cloud-messaging-gcm-for-android-and-push-notifications/][1] , implemented gcm android device, problem dont know how trigger gcm server while content updated in db,i need notify each , every update of db user, need watch db using timer task or there default solution keep track of db ?
my server side code :
regid = "my registration id"; string usermessage = request.getparameter("message"); sender sender = new sender(google_server_key); message message = new message.builder().timetolive(30) .delaywhileidle(true).adddata(message_key, usermessage).build(); result = sender.send(message, regid, 1);
have tried many solution till not getting exact solution, suggestion, ideas or related links welcome in advance
without knowing specific functionality of server , app, can offer general solution.
each process in server performs db updates have pushed android devices via gcm can write messages , registration ids kind of queue.
then can have process (or processes) consume queue of gcm messages, , send them google. these processes can handle failures (retry sending messages in case of temporary failures), , update database of registration ids if receive responses canonical registration ids or errors such invalidregistration or notregistered.
Comments
Post a Comment