Exemple #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())
                    {
                        ParsePush.parsePushNotificationReceived.Invoke(ParseInstallation.CurrentInstallation, new ParsePushNotificationEventArgs(ParsePush.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 {
                ParseWakefulHelper.CompleteWakefulIntent(intent);
            }
        }
 public void Initialize()
 {
     if (ManifestInfo.HasPermissionForGCM())
     {
         GcmRegistrar.GetInstance().Register();
     }
 }