summaryrefslogtreecommitdiff
path: root/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/RegistrationIntentService.java
diff options
context:
space:
mode:
authorRene Ae <aehtyb@gmail.com>2015-11-30 17:57:27 -0600
committerRene Ae <aehtyb@gmail.com>2015-11-30 17:57:27 -0600
commit99abed397b0c046143d7d6ba7bd0b61eac829e25 (patch)
treeeeceffcc76dd2ff201b8c62e43c4aaff47fc7d8e /StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/RegistrationIntentService.java
parentbe27ea977b1e7c7903275b42530a81a8e43d7a9b (diff)
parentded2f8928dd509acc8d4ae1e4131b622c7bb4d9c (diff)
Merge branch 'master' of https://github.com/okfocus/stone-island
Diffstat (limited to 'StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/RegistrationIntentService.java')
-rw-r--r--StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/RegistrationIntentService.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/RegistrationIntentService.java b/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/RegistrationIntentService.java
new file mode 100644
index 00000000..c4489fc1
--- /dev/null
+++ b/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/RegistrationIntentService.java
@@ -0,0 +1,42 @@
+package com.adobe.phonegap.push;
+
+import android.content.Context;
+
+import android.app.IntentService;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.util.Log;
+
+import com.google.android.gms.gcm.GoogleCloudMessaging;
+import com.google.android.gms.iid.InstanceID;
+
+import java.io.IOException;
+
+public class RegistrationIntentService extends IntentService implements PushConstants {
+ public static final String LOG_TAG = "PushPlugin_RegistrationIntentService";
+
+ public RegistrationIntentService() {
+ super(LOG_TAG);
+ }
+
+ @Override
+ protected void onHandleIntent(Intent intent) {
+ SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences(COM_ADOBE_PHONEGAP_PUSH, Context.MODE_PRIVATE);
+
+ try {
+ InstanceID instanceID = InstanceID.getInstance(this);
+ String senderID = sharedPreferences.getString(SENDER_ID, "");
+ String token = instanceID.getToken(senderID,
+ GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
+ Log.i(LOG_TAG, "new GCM Registration Token: " + token);
+
+ // save new token
+ SharedPreferences.Editor editor = sharedPreferences.edit();
+ editor.putString(REGISTRATION_ID, token);
+ editor.commit();
+
+ } catch (Exception e) {
+ Log.d(LOG_TAG, "Failed to complete token refresh", e);
+ }
+ }
+} \ No newline at end of file