Esempio n. 1
0
        /// <summary>
        /// Handle push intent from <see cref="ParsePushBroadcastReceiver"/>.
        /// </summary>
        /// <param name="intent">The intent to be handled.</param>
        protected override void OnHandleIntent(Intent intent)
        {
            Task task = Task.FromResult(0);

            try {
                // Assume only GCM intent is received here.
                switch (intent.Action)
                {
                case ParsePushBroadcastReceiver.ActionGcmRegisterResponse:
                    task = GcmRegistrar.GetInstance().HandleRegistrationIntentAsync(intent);
                    break;

                case ParsePushBroadcastReceiver.ActionGcmReceive:
                    if (ManifestInfo.HasPermissionForGCM())
                    {
                        AVPush.parsePushNotificationReceived.Invoke(AVInstallation.CurrentInstallation, new AVPushNotificationEventArgs(AVPush.PushJson(intent)));
                    }
                    break;

                default:
                    // TODO (hallucinogen): Prints error that we don't support other intent.
                    break;
                }
                // Wait for its completion with timeout.
                task.Wait(IntentServiceHandlerTimeout);
            } finally {
                AVWakefulHelper.CompleteWakefulIntent(intent);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Receives push notification and start <see cref="ParsePushService"/> to handle the notification
 /// payload.
 /// </summary>
 /// <remarks>
 /// See <see cref="BroadcastReceiver.OnReceive(Context, Intent)" /> for complete documentation.
 /// </remarks>
 /// <seealso cref="ParsePushService"/>
 /// <param name="context"></param>
 /// <param name="intent"></param>
 public override sealed void OnReceive(Context context, Intent intent)
 {
     intent.SetClass(context, typeof(ParsePushService));
     AVWakefulHelper.StartWakefulService(context, intent);
 }