static async Task OnRegistered(string token) { var userId = "???"; await Api.Post("v1/authentication/push-notification/register", new { User = userId, InstallationToken = UIRuntime.GetInstallationToken(), PushNotificationToken = token, DeviceType = Device.Platform }); }
static async Task OnUnRegistered() { var successful = await Api.Post("api/v1/authentication/push-notification/unregister", new { InstallationToken = UIRuntime.GetInstallationToken() }); if (!successful) { Log.Error("The server failed to unregister this device from receiving push notifications."); } }
public static async Task <bool> Logout() { var successful = await Post <bool>("api/v1/auth/logout", new { SessionToken = BaseApi.GetSessionToken(), InstallationToken = UIRuntime.GetInstallationToken() // To disable sending push notifications to this device. }); if (successful) { IO.File("SessionToken.txt").Delete(); User.Current = null; Nav.DisposeCache(); await Api.DisposeCache(); } return(successful); }
/// <param name="registerationToken">The registration token provided by Apple, Google or Microsoft.</param> static async Task OnRegistered(string registerationToken) { if (User.Current == null) { throw new Exception("A non-logged in user was registered for push notification!"); } var successful = await Api.Post("api/v1/authentication/push-notification/register", new { User = User.Current.Id, InstallationToken = UIRuntime.GetInstallationToken(), PushNotificationToken = registerationToken, DeviceType = OS.Platform }); if (!successful) { throw new Exception("The server failed to register the push notification token."); } }
public static async Task <bool> Login(string email, string password) { var sessionToken = await Post <string>("api/v1/auth/login", new { Email = email, Password = password, installationToken = UIRuntime.GetInstallationToken() }); if (sessionToken.LacksValue()) { return(false); } IO.File("SessionToken.txt").WriteAllText(sessionToken); if (!await User.LoadFromSessionToken()) { return(false); } await UI.Services.PushNotificationListener.Register(); return(true); }
static async Task OnUnRegistered() { await Api.Post("v1/authentication/push-notification/unregister", new { InstallationToken = UIRuntime.GetInstallationToken() }); }