コード例 #1
0
        static async Task DoUnRegisterOnThreadPool(object userState)
        {
            try
            {
                await Task.Run(() => FirebaseInstanceId.Instance.DeleteInstanceId());

                await UnRegistered.RaiseOn(Thread.Pool, userState);
            }
            catch (Exception ex)
            {
                await ReceivedError.RaiseOn(Thread.Pool, "Failed to un-register PushNotification: " + ex);
            }
        }
コード例 #2
0
            public override void OnNewToken(string p0)
            {
                base.OnNewToken(p0);

                Thread.Pool.RunAction(async() =>
                {
                    try
                    {
                        var token = p0;
                        await Registered.RaiseOn(Thread.Pool, token);
                        Log.For(this).Debug("Refreshed token: " + token);
                    }
                    catch (Exception ex)
                    {
                        await ReceivedError.RaiseOn(Thread.Pool,
                                                    "Failed to refresh the installation ID: " + ex);
                    }
                });
            }
コード例 #3
0
        static async Task DoRegister()
        {
            try
            {
                Firebase.FirebaseApp.InitializeApp(UIRuntime.CurrentActivity);

#if DEBUG
                try { await Task.Run(() => FirebaseInstanceId.Instance.DeleteInstanceId()); } catch { }
#endif

                var result = await FirebaseInstanceId.Instance.GetInstanceId().AsAsync <IInstanceIdResult>();

                if (result == null)
                {
                    throw new Exception("Failed to obtain the token");
                }

                await Registered.RaiseOn(Thread.Pool, result.Token);
            }
            catch (Exception ex)
            {
                await ReceivedError.RaiseOn(Thread.Pool, "Failed to register PushNotification: " + ex);
            }
        }
コード例 #4
0
 static void Init()
 {
     UIRuntime.DidReceiveRemoteNotification += OnMessageReceived;
     UIRuntime.RegisteredForRemoteNotifications.Handle(OnRegisteredSuccess);
     UIRuntime.FailedToRegisterForRemoteNotifications.Handle((error) => ReceivedError.RaiseOn(Thread.Pool, error.LocalizedDescription));
 }