Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
edatkinvey committed Feb 23, 2015
1 parent a56c7a6 commit 960e0d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
15 changes: 14 additions & 1 deletion Kinvey-Xamarin-Android/Push/KinveyGCMService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions Kinvey-Xamarin-Android/Push/Push.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down

0 comments on commit 960e0d7

Please sign in to comment.