public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { // Modify device token for compatibility Azure var token = deviceToken.Description; token = token.Trim('<', '>').Replace(" ", ""); // You need the Settings plugin for this! Settings.DeviceToken = token; // TODO add your own access key var hub = new SBNotificationHub("Endpoint=sb://xamarinnotifications-ns.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=<your key here>", "xamarinnotifications"); NSSet tags = null; // create tags if you want hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { var alert = new UIAlertView("ERROR!", errorCallback.ToString(), null, "OK", null); alert.Show(); } }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(Constants.ListenConnectionString, Constants.NotificationHubName); Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } Preferences.Set("appToken", deviceToken.ToString()); string[] myTags = new[] { Preferences.Get("appTags", string.Empty) }; if (myTags.Length == 0) { myTags = new string[] { "0,1,2,3,4,5" } } ; //NSSet tags = null; // create tags if you want //NSSet tags = new NSSet(new string[] { "0,", "1,", "2,", "3,", "4,", "5" }); NSSet tags = new NSSet(myTags); Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { //LNBFans.Helpers.SettingHelper.CreateTagFile(); Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { string originalDeviceToken = deviceToken.ToString(); DEVICE_TOKEN = originalDeviceToken.Trim('<').Trim('>').Replace(" ", ""); BaseSingleton <GlobalSetting> .Instance.MessagingDeviceToken = DEVICE_TOKEN; MessagingCenter.Send <object>(this, "device_token"); // Create a new notification hub with the connection string and hub path Hub = new SBNotificationHub(ConnectionString, NotificationHubPath); // Unregister any previous instances using the device token Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { // Error unregistering return; } // Register this device with the notification hub Hub.RegisterNativeAsync(deviceToken, null, (registerError) => { if (registerError != null) { // Error registering } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(Constants.ConnectionString, Constants.NotificationHubPath); Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } var tags_list = new List <string>() { }; var mainviewModel = MainViewModel.GetInstance(); if (mainviewModel.Employee != null) { var userId = mainviewModel.Employee.EmployeeId; tags_list.Add("userId:" + userId); } var tags = new NSSet(tags_list.ToArray()); Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public void RegisterForRemoteHubNotifications(string notificationHubName, string connectionString, string channelName, string[] tags) { Hub = new SBNotificationHub(connectionString, notificationHubName); Hub.UnregisterAllAsync(DeviceToken, (error) => { if (error != null) { if (this.NotificationError != null) { this.NotificationError(this, new AzureNotificationErrorEventArgs("Error calling Unregister: " + error.ToString())); } return; } //// NSSet tags = null; // create tags if you want Hub.RegisterNativeAsync(DeviceToken, new NSSet(tags), (errorCallback) => { if (errorCallback != null) { if (this.NotificationError != null) { this.NotificationError(this, new AzureNotificationErrorEventArgs("RegisterNativeAsync error: " + errorCallback.ToString())); } Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(App.ListenConnectionString, Constants.NotificationHubPath); Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } // create tags if you want // Refer to : https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-routing-tag-expressions/ NSSet tags = null; Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication app, NSData deviceToken) { // Connection string from your azure dashboard var cs = SBConnectionString.CreateListenAccess( new NSUrl(EnvironmentConstants.AzureListenAccessEndPoint), EnvironmentConstants.AzurePushAccess); // Register our information with Azure var hub = new SBNotificationHub(cs, EnvironmentConstants.AzureNamespace); hub.RegisterNativeAsync(deviceToken, null, err => { if (err != null) { UIAlertViewHelpers.ShowAlert( "Uh Oh!", "There was a problem registering with push notifications. Email [email protected]", "Got it!"); } else { Console.WriteLine("Success"); } }); }
public void RegisteredForRemoteNotifications(NSData deviceToken) { Hub = new SBNotificationHub(PushNotificationCredentials.AzureListenConnectionString, PushNotificationCredentials.AzureNotificationHubName); Hub.UnregisterAllAsync(deviceToken, error => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = new NSSet(PushNotificationCredentials.Tags); Hub.RegisterNativeAsync(deviceToken, tags, errorCallback => { if (errorCallback != null) { Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); // Register for Notifications UIApplication.SharedApplication.RegisterForRemoteNotificationTypes( UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(PushNotificationConstants.HUB_CONNECTION_STRING, PushNotificationConstants.HUB_NAME); string normalizedDeviceToken = deviceToken.Description .Replace(" ", string.Empty) .Replace("<", string.Empty) .Replace(">", string.Empty).ToUpper(); System.Diagnostics.Debug.WriteLine($"******************************************"); System.Diagnostics.Debug.WriteLine($"Device Token: {normalizedDeviceToken}"); System.Diagnostics.Debug.WriteLine($"******************************************"); Hub.UnregisterAllAsync(deviceToken, error => { if (error != null) { System.Diagnostics.Debug.WriteLine(new AggregateException("Erro ao registrar NotificationHub", new NSErrorException(error))); return; } NSSet tags = null; Hub.RegisterNativeAsync(deviceToken, tags, errorCallback => { if (errorCallback != null) { System.Diagnostics.Debug.WriteLine(new AggregateException("Error at registering native hub", new NSErrorException(errorCallback))); } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { var hubName = String.Empty; var hubConnectionString = String.Empty; #if DEBUG hubName = Settings.AzureNotificationHubNameSandbox; hubConnectionString = Settings.AzureNotificationHubConnectionStringSandbox; #else hubName = Settings.AzureNotificationHubNameProd; hubConnectionString = Settings.AzureNotificationHubConnectionStringProd; #endif _Hub = new SBNotificationHub(hubConnectionString, hubName); _Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = null; // create tags if you want _Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(Constants.ListenConnectionString, Constants.NotificationHubName); List <string> tagList = new List <string>(); //add global identifier tagList.Add("buyplane"); if (Settings.IsRegistered) { tagList.Add("userid:" + Settings.UserID.ToString()); } Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { System.Diagnostics.Debug.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = new NSSet(tagList.ToArray()); Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { System.Diagnostics.Debug.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public void RegisteredForRemoteNotifications(NSData deviceToken) { Console.WriteLine("deviceToken: " + deviceToken); Hub = new SBNotificationHub(PushNotificationCredentials.AzureListenConnectionString, PushNotificationCredentials.AzureNotificationHubName); Hub.UnregisterAllAsync(deviceToken, error => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = new NSSet(PushNotificationCredentials.Tags); Hub.RegisterNativeAsync(deviceToken, tags, errorCallback => { if (errorCallback != null) { Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication app, NSData deviceToken) { if (ApiKeys.AzureServiceBusUrl == nameof(ApiKeys.AzureServiceBusUrl)) { return; } // Connection string from your azure dashboard var cs = SBConnectionString.CreateListenAccess( new NSUrl(ApiKeys.AzureServiceBusUrl), ApiKeys.AzureKey); // Register our info with Azure var hub = new SBNotificationHub(cs, ApiKeys.AzureHubName); hub.RegisterNativeAsync(deviceToken, null, err => { if (err != null) { Console.WriteLine("Error: " + err.Description); } else { Console.WriteLine("Success"); } }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { //JPUSHService.RegisterDeviceToken(deviceToken); try { _deviceToken = deviceToken; Hub = new SBNotificationHub(ConnectionString, NotificationHubPath); Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = null; // create tags if you want Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); } catch (Exception ex) { Console.WriteLine("RegisterNativeAsync exception:" + ex.Message.ToString()); } }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(AppConstants.ListenConnectionString, AppConstants.NotificationHubName); // update registration with Azure Notification Hub Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Debug.WriteLine($"Unable to call unregister {error}"); return; } var tags = new NSSet(AppConstants.SubscriptionTags.ToArray()); Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { Debug.WriteLine($"RegisterNativeAsync error: {errorCallback}"); } }); var templateExpiration = DateTime.Now.AddDays(120).ToString(System.Globalization.CultureInfo.CreateSpecificCulture("en-US")); Hub.RegisterTemplateAsync(deviceToken, "defaultTemplate", AppConstants.APNTemplateBody, templateExpiration, tags, (errorCallback) => { if (errorCallback != null) { if (errorCallback != null) { Debug.WriteLine($"RegisterTemplateAsync error: {errorCallback}"); } } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { try { var connectionString = Settings.NotificationConnectionString; var hubPath = Settings.NotificationHubPath; _hub = new SBNotificationHub(connectionString, hubPath); _hub.UnregisterAllAsync(deviceToken, error => { if (error != null) { Debug.WriteLine($"Error calling Unregister: {0}", error.ToString()); return; } var tags = new NSSet(Settings.UserId.ToString()); // create tags if you want _hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { Debug.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); Debug.WriteLine($"RegisteredForRemoteNotifications, DeviceToken = {deviceToken}"); } catch (Exception ex) { Mvx.Resolve <IExceptionService>().HandleException(ex); } }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { // Create a new notification hub with the connection string and hub path _hub = new SBNotificationHub(ConnectionString, NotificationHubPath); // Unregister any previous instances using the device token _hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { // Error unregistering Console.WriteLine($"Error: {error.Description}"); return; } // Register this device with the notification hub _hub.RegisterNativeAsync(deviceToken, null, (registerError) => { if (registerError != null) { // Error registering Console.WriteLine($"Error: {error.Description}"); } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { _notificationHub = new SBNotificationHub(KHubConnectionString, KHubnameString); _notificationHub.RegisterNativeAsync(deviceToken, null, (NSError error) => { }); }
private async void Navigation() { TokenRegistration token = new TokenRegistration(); iniciarSesionButton.Enabled = false; AfiliadosSeguroPopular afiliado = new AfiliadosSeguroPopular(); var afiliadoSP = await afiliado.GetDataFromAPi(polizaTextField.Text, numeroConsecutivoTextField.Text); if (afiliadoSP.folio != null) { ConfiguracionApp config = new ConfiguracionApp(); config.GuardarConfiguracion(afiliadoSP); var plist = NSUserDefaults.StandardUserDefaults; try { Hub = new SBNotificationHub(Constants.ConnectionString, Constants.NotificationHubPath); Hub.UnregisterAllAsync(token.Token, (error) => { if (error != null) { return; } NSSet tags = new NSSet(plist.StringForKey("userFolio"), plist.StringForKey("userTag")); // create tags if you want Hub.RegisterNativeAsync(token.Token, tags, (errorCallback) => { if (errorCallback != null) { } }); }); } catch (Exception ex) { } this.PerformSegue("loginUserSeguroPopular", this); } else { iniciarSesionButton.Enabled = true; UIAlertView alert = new UIAlertView() { Message = "Usted no esta afiliado en nuestro sistema.", Title = "Seguro Popular Hidalgo" }; alert.AddButton("Ok"); alert.Show(); } }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { _hub = new SBNotificationHub(KConnectionString, KHubString); _hub.RegisterNativeAsync(deviceToken, null, (NSError error) => { if (error != null) { Console.WriteLine(error.Description); } }); }
public void Register(string connectionString, string hubName, string token, string[] tags) { hub = new SBNotificationHub(connectionString, hubName); hub.RegisterNativeAsync(token, new NSSet(tags), err => { if (err != null) { Console.WriteLine("Error: " + err.Description); } else { Console.WriteLine("Success"); } }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { _hub = new SBNotificationHub(notificationUrl, notificationHubName); _hub.UnregisterAllAsync(deviceToken); var deviceId = Convert.ToBase64String(deviceToken.ToArray()); var tag = Guid.NewGuid().ToString(); var tags = new List <string> { tag }; _hub.RegisterNativeAsync(deviceToken, new NSSet(tags.ToArray())); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(AzureNotificationConstants.ListenConnectionString, AzureNotificationConstants.NotificationHubName); Hub.UnregisterAll(deviceToken, (error) => { if (error != null) { System.Diagnostics.Debug.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = null; // create tags if you want Hub.RegisterNativeAsync(deviceToken, tags); }); }
public override void RegisteredForRemoteNotifications(UIApplication app, NSData deviceToken) { #if ENABLE_TEST_CLOUD #else // Register our info with Azure var hub = new SBNotificationHub(ApiKeys.AzureListenConnection, ApiKeys.AzureHubName); NSSet tags = (BaseViewModel.User?.Role != null) ? new NSSet(Sealegs.DataObjects.SealegsUserRole.RoleHierarchy.ToList().SkipWhile(r => r.Id.ToLower() != BaseViewModel.User?.Role.Id.ToLower()).Select(r => r.RoleName).ToArray()) : null; hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { Console.WriteLine(errorCallback != null ? "Error: " + errorCallback.Description : "Success"); } }); return; hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } tags = !String.IsNullOrEmpty(BaseViewModel.User?.Role?.RoleName) ? new NSSet(BaseViewModel.User?.Role?.RoleName) : null; hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { Console.WriteLine(errorCallback != null ? "Error: " + errorCallback.Description : "Success"); } }); }); #endif }
public override void RegisteredForRemoteNotifications(UIApplication app, NSData deviceToken) { // TODO add your own access key var hub = new SBNotificationHub("Endpoint=sb://ppnotifications.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=7VbttLtftP1IDZS+yH3afWuL+jVlGOv2ghzvSeC8xms=", "tmtknotificationhub"); NSSet tags = null; // create tags if you want hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { var alert = new UIAlertView("ERROR!", errorCallback.ToString(), null, "OK", null); alert.Show(); } }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { // NOTE: Don't call the base implementation on a Model class // see http://docs.xamarin.com/guides/ios/application_fundamentals/delegates,_protocols,_and_events Hub = new SBNotificationHub(Constants.ConnectionString, Constants.NotificationHubPath); this.DeviceToken = deviceToken; try{ Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } iOSLoginManager loginManager = iOSLoginManager.Instance; string username = loginManager.GetUsername(); string travelerId = loginManager.GetTravelerId().ToString(); string[] tagsArray = new string[2]; tagsArray[0] = username; tagsArray[1] = travelerId; NSSet tags = new NSSet(tagsArray); Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("app_action", "notifications", "notifications registration error", null).Build()); Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } else { GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("app_action", "notifications launched", "notifications registration complete", null).Build()); } }); }); }catch (Exception ex) { Console.WriteLine("Error" + ex.ToString()); } }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(MobileServiceClientIOSConstants.AzurePushConnectionString, MobileServiceClientConstants.NotificationHubName); Hub.UnregisterAllAsync(deviceToken, error => { if (error != null) { LogError($"Error Unregistering: {error}"); } Hub.RegisterNativeAsync(deviceToken, null, registerError => { if (registerError != null) { LogError($"Error Registering: {registerError}"); } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(ConfigurationSettings.HUB_CONNEXTION_STRING, ConfigurationSettings.HUB_NAME); Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = null; // create tags if you want Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { notificationHub = new SBNotificationHub(AppSettings.NotificationHubConnectionString, AppSettings.NotificationHubPath); notificationHub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = null; // create tags if you want notificationHub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken) { // Connection string from your azure dashboard var cs = SBConnectionString.CreateListenAccess( new NSUrl("sb://" + HUB_NAME + "-ns.servicebus.windows.net/"), HUB_LISTEN_SECRET); // Register our info with Azure var hub = new SBNotificationHub (cs, HUB_NAME); hub.RegisterNativeAsync (deviceToken, null, err => { if (err != null) { Console.WriteLine("Error: " + err.Description); homeViewController.RegisteredForNotifications ("Error: " + err.Description); } else { Console.WriteLine("Success"); homeViewController.RegisteredForNotifications ("Successfully registered for notifications"); } }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(Core.Constants.ConnectionString, Core.Constants.NotificationHubPath); Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Debug.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = null; Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) Debug.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub("Endpoint=sb://rcicamobilenotificationnamespace.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=JRkPcobvvJZzpw6ifQXx5czgNKXj3yjQaM33p+65wls=", "RCICAMobileNotificationHub"); Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = null; // create tags if you want Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public override void RegisteredForRemoteNotifications (UIApplication app, NSData deviceToken) { // Connection string from your azure dashboard var cs = SBConnectionString.CreateListenAccess ( new NSUrl("sb://YOUR-SERVICE-NAME-HERE-ns.servicebus.windows.net/"), "YOUR-API-KEY-HERE="); // Register our information with Azure var hub = new SBNotificationHub (cs, "vafiedpushtest"); hub.RegisterNativeAsync (deviceToken, null, err => { if (err != null) { Console.WriteLine ("Error: " + err.Description); } else { Console.WriteLine ("Success"); } }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { // NOTE: Don't call the base implementation on a Model class // see http://docs.xamarin.com/guides/ios/application_fundamentals/delegates,_protocols,_and_events Hub = new SBNotificationHub(Constants.ConnectionString, Constants.NotificationHubPath); Hub.UnregisterAllAsync (deviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = null; // create tags if you want Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); }); }); }
public override void RegisteredForRemoteNotifications(UIApplication app, NSData deviceToken) { #if ENABLE_TEST_CLOUD #else if (ApiKeys.AzureServiceBusUrl == nameof(ApiKeys.AzureServiceBusUrl)) return; // Connection string from your azure dashboard var cs = SBConnectionString.CreateListenAccess( new NSUrl(ApiKeys.AzureServiceBusUrl), ApiKeys.AzureKey); // Register our info with Azure var hub = new SBNotificationHub (cs, ApiKeys.AzureHubName); hub.RegisterNativeAsync (deviceToken, null, err => { if (err != null) Console.WriteLine("Error: " + err.Description); else Console.WriteLine("Success"); }); #endif }
public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken) { if (deviceToken != null) { Hub = new SBNotificationHub (Constants.ConnectionString, Constants.NotificationHubPath); Hub.UnregisterAllAsync (deviceToken, (error) => { if (error != null) { Console.WriteLine ("Error calling Unregister: {0}", error.ToString ()); return; } NSSet tags = null; var settingsService = ServiceLocator.Current.GetInstance<ISettingsService> (); if (!string.IsNullOrWhiteSpace (settingsService.EmailAddress)) { tags = new NSSet (new string[] { "platform:iOS", "emailAddress:" + settingsService.EmailAddress }); } else { tags = new NSSet (new string[] { "platform:iOS" }); } Hub.RegisterNativeAsync (deviceToken, tags, (errorCallback) => { if (errorCallback != null) Console.WriteLine ("RegisterNativeAsync error: " + errorCallback.ToString ()); }); }); } }
public void RegisterForRemoteHubNotifications(string notificationHubName, string connectionString, string channelName, string[] tags) { Hub = new SBNotificationHub(connectionString, notificationHubName); Hub.UnregisterAllAsync(DeviceToken, (error) => { if (error != null) { if (this.NotificationError != null) this.NotificationError(this, new AzureNotificationErrorEventArgs("Error calling Unregister: " + error.ToString())); return; } //// NSSet tags = null; // create tags if you want Hub.RegisterNativeAsync(DeviceToken, new NSSet(tags), (errorCallback) => { if (errorCallback != null) { if (this.NotificationError != null) this.NotificationError(this, new AzureNotificationErrorEventArgs("RegisterNativeAsync error: " + errorCallback.ToString())); Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }