android - InstanceID and Regid GCM -
as read, function gcm.register() deprecated. , may use instanceid.gettoken() instead...
i use described here every time run app, new regid (instance id)..
here how registered :
@override protected string doinbackground(object[] voids) { string msg = ""; if (gcm == null) { gcm = googlecloudmessaging.getinstance(myapp.getcontext()); } instanceid instanceid = instanceid.getinstance(context1); entryactivity. regid = null; try { entryactivity.regid = instanceid.gettoken(constantsgcm.senderid_projectid, googlecloudmessaging.instance_id_scope, null); log.d("reg---", "========================>>>- regid= " + entryactivity.regid); } catch (ioexception e) { e.printstacktrace(); } if (entryactivity.regid != null) try { storeregistrationid(context1, entryactivity.regid); } catch (packagemanager.namenotfoundexception e) { e.printstacktrace(); } log.d("reg---", "- " + msg + "regid= " + entryactivity.regid); return msg; }
and sent "regid" server , save database, until everythig worked fine, when send message server via gcm (gcm.send(...); ) , call "from" field of message (in server side) different regid, , every time restart app , send new regid (for each instace regid changed).
how use instance id constant regid, read documentations did not undersatnd how!
Comments
Post a Comment