From 960e0d7ffe19f4e42bf7f9d4e88a3d087bc4c39f Mon Sep 17 00:00:00 2001 From: Edward Fleming Date: Mon, 23 Feb 2015 16:59:29 -0500 Subject: [PATCH] cleanup --- Kinvey-Xamarin-Android/Push/KinveyGCMService.cs | 15 ++++++++++++++- Kinvey-Xamarin-Android/Push/Push.cs | 5 ++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Kinvey-Xamarin-Android/Push/KinveyGCMService.cs b/Kinvey-Xamarin-Android/Push/KinveyGCMService.cs index 46a28983..f869fe6c 100644 --- a/Kinvey-Xamarin-Android/Push/KinveyGCMService.cs +++ b/Kinvey-Xamarin-Android/Push/KinveyGCMService.cs @@ -19,7 +19,7 @@ public KinveyGCMService () private const string MESSAGE_FROM_GCM = "msg"; - public static void RunIntentInService(Context context, Intent intent) + public static void AcquireWakeLock(Context context, Intent intent) { lock (LOCK) { @@ -35,6 +35,19 @@ public static void RunIntentInService(Context context, Intent intent) protected override void OnHandleIntent(Intent intent) { + + lock (LOCK) + { + if (sWakeLock == null) + { + var pm = PowerManager.FromContext(this.ApplicationContext); + sWakeLock = pm.NewWakeLock(WakeLockFlags.Partial, "KinveyGCM"); + } + } + + sWakeLock.Acquire(); + + try { string action = intent.Action; diff --git a/Kinvey-Xamarin-Android/Push/Push.cs b/Kinvey-Xamarin-Android/Push/Push.cs index 7da8bb2c..6dda08be 100644 --- a/Kinvey-Xamarin-Android/Push/Push.cs +++ b/Kinvey-Xamarin-Android/Push/Push.cs @@ -31,7 +31,7 @@ public void Initialize(Context appContext){ ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences (appContext); string alreadyInitialized = prefs.GetString (GCM_ID, ""); - if (false && alreadyInitialized.Length > 0) { + if (alreadyInitialized.Length > 0) { //this device has already registered for push return; } @@ -42,8 +42,7 @@ public void Initialize(Context appContext){ try{ var gcm = GoogleCloudMessaging.GetInstance(appContext); - var gcmID = gcm.Register("12 3"); - //var gcmID = gcm.Register(senders); + var gcmID = gcm.Register(senders); Logger.Log ("-------sender ID is: " + senders); Logger.Log ("-------GCM ID is: " + gcmID);