/// <summary> /// Requests a push channel url and uploads this to Mobile Services /// devices table /// </summary> private async void RegisterDevice() { PushNotificationChannel channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); channel.PushNotificationReceived += channel_PushNotificationReceived; string installationId = await InstallationId.GetInstallationId(); await _devicesTable.InsertAsync( new Device { UserId = User.UserId, ChannelUri = channel.Uri.ToString(), InstallationId = installationId }); }
/// <summary> /// Requests a push channel URI and uploads this to Windows Azure Mobile Service /// devices table /// </summary> private async void RegisterDeviceAsync() { PushNotificationChannel channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); channel.PushNotificationReceived += channel_PushNotificationReceived; string installationId = InstallationId.GetInstallationIdAsync(); // The server side script devices.insert.js will ensure that it creates a new row only when a new User + Device combination is getting added. await devicesTable.InsertAsync( new Device { UserId = User.UserId, ChannelUri = channel.Uri.ToString(), InstallationId = installationId }); }