Open a dialogue when notification is received.

EmyMa341EmyMa341 ✭✭USMember ✭✭
edited November 2015 in Xamarin.Android

I am posting function where I am receiving notification. I followed Xamarin walk through to implement GCM notification for android.

 public override void OnReceive(Context context, Intent intent) {
            PowerManager.WakeLock sWakeLock;
            var pm = PowerManager.FromContext(context);
            sWakeLock = pm.NewWakeLock(WakeLockFlags.Partial, "GCM Broadcast Reciever Tag");
            sWakeLock.Acquire();
            //handle the notification here
            String action = intent.Action;
            if (action != null)
            {
                if (action.Equals("com.google.android.c2dm.intent.RECEIVE"))
                {
                    string workflowid = intent.GetStringExtra("workflowid");
                    string beaconid = intent.GetStringExtra("beaconid");
                    if (!string.IsNullOrEmpty(workflowid))
                    {
                        Console.WriteLine(workflowid);
                        Console.WriteLine(beaconid);
                    }
                }
            }
            sWakeLock.Release();
        }
Sign In or Register to comment.