public async Task <bool> Authenticate(String username, object uiObject)//UIViewController view) { try { if (MobileService.CurrentUser != null && !string.IsNullOrEmpty(MobileService.CurrentUser.UserId)) { return(true); } this.Username = username; ServiceHelper.MobileService.CurrentUser = await PlatformSpecific.GetInstance().Authenticate(MobileService, uiObject); RegisterWithNotificationHubs(); return(true); } catch (Exception ex) { PlatformSpecific.GetInstance().LogInfo("Error authenticating: " + ex.Message); return(false); } }
private async void RegisterWithNotificationHubs() { if (!String.IsNullOrEmpty(this.PushIdentifier)) { NotificationHubRegistration registration = new NotificationHubRegistration() { Platform = PlatformSpecific.GetInstance().Platform, PushIdentifier = this.PushIdentifier, Username = this.Username }; var response = await MobileService.InvokeApiAsync <NotificationHubRegistration, ApiResponse>("RegisterforPush", registration); if (response.Message == "Registered") { PlatformSpecific.GetInstance().LogInfo("Registered with Notification Hubs"); } else { PlatformSpecific.GetInstance().LogInfo("Issue registering for Notification Hubs"); } } }
public static void SetPlatform(PlatformSpecific platform) { ThisPlatform = platform; }