Exemple #1
0
        public void Register()
        {
            AVInstallation installation = AVInstallation.CurrentInstallation;

            lock (mutex) {
                if (installation.DeviceToken == null && request == null)
                {
                    var    metadata      = ManifestInfo.GetApplicationMetaData();
                    object senderIdExtra = null;
                    if (metadata != null)
                    {
                        senderIdExtra = metadata.Get(ExtraSenderId);
                    }

                    string senderIds = ParseGcmSenderId;
                    if (senderIdExtra != null)
                    {
                        string senderId = getActualSenderIdFromExtra(senderIdExtra);

                        if (senderId != null)
                        {
                            senderIds += "," + senderId;
                        }
                        else
                        {
                            Android.Util.Log.Error("parse.GcmRegistrar", "Found " + ExtraSenderId + " <meta-data> element with value \""
                                                   + senderIdExtra.ToString() + "\", but the value is missing the expected \"id:\" prefix");
                        }
                    }
                    request = Request.CreateAndSend(this.context, senderIds);
                }
            }
        }
Exemple #2
0
 public Task ExecuteAVInstallationSaveHookAsync(AVInstallation installation)
 {
     return(GetChannelTask.ContinueWith(t => {
         installation.SetIfDifferent("deviceUris", new Dictionary <string, string> {
             { defaultChannelTag, t.Result.Uri }
         });
     }));
 }
Exemple #3
0
 public Task ExecuteAVInstallationSaveHookAsync(AVInstallation installation)
 {
     return(getToastUriTask.Value.ContinueWith(t => {
         installation.SetIfDifferent("deviceUris", t.Result == null ? null :
                                     new Dictionary <string, string> {
             { toastChannelTag, t.Result }
         });
     }));
 }
 public IDictionary<string, object> Encode(AVInstallation installation)
 {
     var state = installation.GetState();
       var data = PointerOrLocalIdEncoder.Instance.Encode(state.ToDictionary(x => x.Key, x => x.Value)) as IDictionary<string, object>;
       data["objectId"] = state.ObjectId;
       if (state.CreatedAt != null) {
     data["createdAt"] = state.CreatedAt.Value.ToString(ISO8601Format);
       }
       if (state.UpdatedAt != null) {
     data["updatedAt"] = state.UpdatedAt.Value.ToString(ISO8601Format);
       }
       return data;
 }
Exemple #5
0
        /// <summary>
        /// Handles GCM registration intent from <see cref="ParsePushBroadcastReceiver"/> and saves the GCM registration
        /// id as <see cref="ParseInstallation.CurrentInstallation"/> device token.
        /// </summary>
        /// <remarks>
        /// Should be called by a broadcast receiver or service to handle GCM registration response
        /// intent (com.google.android.c2dm.intent.REGISTRATION).
        /// </remarks>
        /// <param name="intent"></param>
        public Task HandleRegistrationIntentAsync(Intent intent)
        {
            if (intent.Action == ParsePushBroadcastReceiver.ActionGcmRegisterResponse)
            {
                string registrationId = intent.GetStringExtra(ExtraRegistrationId);

                if (registrationId != null && registrationId.Length > 0)
                {
                    Android.Util.Log.Info(LogTag, "GCM registration successful. Registration Id: " + registrationId);
                    AVInstallation installation = AVInstallation.CurrentInstallation;

                    // Set `pushType` via internal `Set` method since we want to skip mutability check.
                    installation.Set("pushType", "gcm");
                    installation.DeviceToken = registrationId;

                    return(installation.SaveAsync());
                }
            }
            return(Task.FromResult(0));
        }
Exemple #6
0
        /// <summary>
        /// Initializes the LeanCloud SDK and begins running network requests created by LeanCloud.
        /// </summary>
        public virtual void Awake()
        {
            Initialize();
            // Force the name to be `AVInitializeBehaviour` in runtime.
            gameObject.name = "AVInitializeBehaviour";

            if (PlatformHooks.IsIOS)
            {
                PlatformHooks.RegisterDeviceTokenRequest((deviceToken) => {
                    if (deviceToken != null)
                    {
                        AVInstallation installation = AVInstallation.CurrentInstallation;
                        installation.SetDeviceTokenFromData(deviceToken);

                        // Optimistically assume this will finish.
                        installation.SaveAsync();
                    }
                });
            }
        }
 public Task ExecuteAVInstallationSaveHookAsync(AVInstallation installation)
 {
     // Do nothing.
     return(Task.FromResult(0));
 }