/// <summary> /// gets the push configuration for an app /// </summary> /// <param name="args">command line args</param> /// <returns>a task</returns> private async Task GetPush(string[] args) { this.ParseLookupPushArgs(args); this.ValidateGetPush(); IAppProfileEntity appProfileEntity = await this.appsManager.ReadAppProfile(this.appHandle); if (appProfileEntity == null) { Console.WriteLine("Cannot find app with appHandle = {0}", this.appHandle); Environment.Exit(0); } IPushNotificationsConfigurationEntity entity = await this.appsManager.ReadPushNotificationsConfiguration(this.appHandle, (PlatformType)this.appPlatformType); if (entity != null) { Console.WriteLine("Push notifications config for appHandle {0} on platform {1}", this.appHandle, (PlatformType)this.appPlatformType); Console.WriteLine(" Enabled = {0}", entity.Enabled); Console.WriteLine(" Key = {0}", entity.Key); Console.WriteLine(" Path = {0}", entity.Path); } else { Console.WriteLine("Cannot find push config for appHandle {0} on platform {1}", this.appHandle, (PlatformType)this.appPlatformType); } }
/// <summary> /// Update push notifications configuration /// </summary> /// <param name="storageConsistencyMode">Storage consistency mode</param> /// <param name="appHandle">App handle</param> /// <param name="platformType">Platform type</param> /// <param name="pushNotificationsConfigurationEntity">Push notifications configuration entity</param> /// <returns>Update push notifications configuration task</returns> public async Task UpdatePushNotificationsConfiguration( StorageConsistencyMode storageConsistencyMode, string appHandle, PlatformType platformType, IPushNotificationsConfigurationEntity pushNotificationsConfigurationEntity) { CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Apps); ObjectTable table = this.tableStoreManager.GetTable(ContainerIdentifier.Apps, TableIdentifier.AppPushNotificationsConfigurationsObject) as ObjectTable; Operation operation = Operation.Replace(table, appHandle, platformType.ToString(), pushNotificationsConfigurationEntity as PushNotificationsConfigurationEntity); await store.ExecuteOperationAsync(operation, storageConsistencyMode.ToConsistencyMode()); }
/// <summary> /// Update push notifications configuration /// </summary> /// <param name="processType">Process type</param> /// <param name="appHandle">App handle</param> /// <param name="platformType">Platform type</param> /// <param name="enabled">A value indicating whether push notifications is enabled</param> /// <param name="path">Gets or sets push notifications hub path. /// Windows: Windows Package SID /// Android: Leave this empty /// iOS: iOS certificate path</param> /// <param name="key">Gets or sets push notifications key. /// Windows: Windows secret key /// Android: Android API key /// iOS: iOS Certificate key</param> /// <param name="pushNotificationsConfiguarationEntity">Push notifications configuration entity</param> /// <returns>Update push notifications configuration task</returns> public async Task UpdatePushNotificationsConfiguration( ProcessType processType, string appHandle, PlatformType platformType, bool enabled, string path, string key, IPushNotificationsConfigurationEntity pushNotificationsConfiguarationEntity) { bool oldEnabled = pushNotificationsConfiguarationEntity.Enabled; string oldPath = pushNotificationsConfiguarationEntity.Path; string oldKey = pushNotificationsConfiguarationEntity.Key; if (oldEnabled && !enabled) { await this.pushNotificationsManager.DeleteHub(platformType, appHandle); } if (!oldEnabled && enabled) { await this.pushNotificationsManager.CreateHub(platformType, appHandle, path, key); } if (oldEnabled && enabled && !(oldPath == path && oldKey == key)) { // Hub key and path have changed. So, we delete the old hub and create the new hub. await this.pushNotificationsManager.DeleteHub(platformType, appHandle); await this.pushNotificationsManager.CreateHub(platformType, appHandle, path, key); } // update the app store table pushNotificationsConfiguarationEntity.Enabled = enabled; pushNotificationsConfiguarationEntity.Path = path; pushNotificationsConfiguarationEntity.Key = key; await this.appsStore.UpdatePushNotificationsConfiguration( StorageConsistencyMode.Strong, appHandle, platformType, pushNotificationsConfiguarationEntity); }
/// <summary> /// update the push notifications configuration for an app /// </summary> /// <param name="args">command line args</param> /// <returns>a task</returns> private async Task UpdatePushConfig(string[] args) { this.ParsePushArgs(args); this.ValidateUpdatePushConfig(); IAppProfileEntity appProfileEntity = await this.appsManager.ReadAppProfile(this.appHandle); if (appProfileEntity == null) { Console.WriteLine("Cannot find app with appHandle = {0}", this.appHandle); Environment.Exit(0); } IPushNotificationsConfigurationEntity entity = await this.appsManager.ReadPushNotificationsConfiguration(this.appHandle, (PlatformType)this.appPlatformType); if (entity != null) { string path = null; string key = null; // Validate routine above ensures that appPlatformType is set to one of the three platforms listed below if (this.appPlatformType == PlatformType.Windows) { path = this.windowsPackageSid; key = this.windowsSecretKey; } else if (this.appPlatformType == PlatformType.Android) { key = this.googleApiKey; } else if (this.appPlatformType == PlatformType.IOS) { path = this.appleCertPath; key = this.appleCertKey; } if (appProfileEntity.DeveloperId == this.appDeveloperId) { await this.appsManager.UpdatePushNotificationsConfiguration( ProcessType.Frontend, this.appHandle, (PlatformType)this.appPlatformType, (bool)this.pushNotificationsEnable, path, key, entity); Console.WriteLine("Updated push notifications configuration for appHandle {0} on platform {1}", this.appHandle, this.appPlatformType); } else { Console.WriteLine( "Incorrect developerId: developerId is {0} for appHandle {1} on platform type {2}", appProfileEntity.DeveloperId, this.appHandle, (PlatformType)this.appPlatformType); } } else { Console.WriteLine("Cannot find push config for appHandle {0} on platform {1}", this.appHandle, (PlatformType)this.appPlatformType); } }