예제 #1
0
        public void Register()
        {
            ParseInstallation installation = ParseInstallation.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 += "," + senderIdExtra;
                        }
                        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);
                }
            }
        }
    public Task TestExistsAsync() {
      var mockInstallationIdController = new Mock<IInstallationIdController>();
      var guid = Guid.NewGuid();
      mockInstallationIdController.Setup(obj => obj.Get()).Returns(guid);

      var controller = new ParseCurrentInstallationController(mockInstallationIdController.Object);
      var installation = new ParseInstallation();

      return controller.SetAsync(installation, CancellationToken.None).OnSuccess(_ => {
        Assert.AreEqual(installation, controller.CurrentInstallation);
        return controller.ExistsAsync(CancellationToken.None);
      }).Unwrap()
      .OnSuccess(t => {
        Assert.IsTrue(t.Result);

        controller.ClearFromMemory();

        return controller.ExistsAsync(CancellationToken.None);
      }).Unwrap()
      .OnSuccess(t => {
        Assert.IsTrue(t.Result);

        controller.ClearFromDisk();

        return controller.ExistsAsync(CancellationToken.None);
      }).Unwrap()
      .OnSuccess(t => {
        Assert.IsFalse(t.Result);
      });
    }
 public Task ExecuteParseInstallationSaveHookAsync(ParseInstallation installation)
 {
     return(GetChannelTask.ContinueWith(t => {
         installation.SetIfDifferent("deviceUris", new Dictionary <string, string> {
             { defaultChannelTag, t.Result.Uri }
         });
     }));
 }
예제 #4
0
 public Task ExecuteParseInstallationSaveHookAsync(ParseInstallation 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(ParseInstallation 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;
 }
예제 #6
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            ParseClient.Initialize("Uf9cDf0SaNEnyM4IolJj3OOKnAgycEfqhcjcBiPJ", "t9HdXpy5hkuit3tY3ov5xTlHmsdMbF9UHNvNXcML");
            this.Startup += async (sender, args) =>
            {
                // This optional line tracks statistics around app opens, including push effectiveness:
                ParseAnalytics.TrackAppOpens(RootFrame);

                // By convention, the empty string is considered a "Broadcast" channel
                // Note that we had to add "async" to the definition to use the await keyword
                await ParsePush.SubscribeAsync("");
            };

            App.installation = Parse.ParseInstallation.CurrentInstallation;

            // Standard XAML initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Language display initialization
            InitializeLanguage();

            // Show graphics profiling information while debugging.
            if (Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Prevent the screen from turning off while under the debugger by disabling
                // the application's idle detection.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }
        }
        /// <summary>
        /// Initializes the Parse SDK and begins running network requests created by Parse.
        /// </summary>
        public virtual void Awake()
        {
            Initialize();
            // Force the name to be `ParseInitializeBehaviour` in runtime.
            gameObject.name = "ParseInitializeBehaviour";

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

                        // Optimistically assume this will finish.
                        installation.SaveAsync();
                    }
                });
            }
        }
예제 #8
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);
                    ParseInstallation installation = ParseInstallation.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));
        }
 public Task ExecuteParseInstallationSaveHookAsync(ParseInstallation installation)
 {
     // Do nothing.
     return(Task.FromResult(0));
 }
 public Task ExecuteParseInstallationSaveHookAsync(ParseInstallation installation) {
   // Do nothing.
   return Task.FromResult(0);
 }
예제 #11
0
 public Task ExecuteParseInstallationSaveHookAsync(ParseInstallation installation)
 {
     return(Task.Run(() => {
         installation.SetIfDifferent("badge", installation.Badge);
     }));
 }