public void RegisterDevice(List <string> channels, DateTime?expiration, BackendlessAPI.Push.PushNotificationsBinding pushNotificationsBinding = null, AsyncCallback <string> callback = null) { if (channels == null) { throw new ArgumentNullException(ExceptionMessage.NULL_CHANNEL_NAME); } if (channels.Count == 0) { _deviceRegistrationDto.AddChannel(DEFAULT_CHANNEL_NAME); } foreach (string channel in channels) { checkChannelName(channel); _deviceRegistrationDto.AddChannel(channel); } if (expiration != null) { _deviceRegistrationDto.Expiration = expiration; } BackendlessAPI.Push.Registrar.RegisterDevice(_deviceRegistrationDto.DeviceId, pushNotificationsBinding, callback); }
private static void MakeInternalRegistration( string channel, PushNotificationsBinding pushNotificationsBinding, AsyncCallback<string> callback ) { var httpNotificationChannel = HttpNotificationChannel.Find( channel ) ?? new HttpNotificationChannel(channel, Backendless.URL); if(httpNotificationChannel.ConnectionStatus.Equals( ChannelConnectionStatus.Connected )) ProceedRegistration( httpNotificationChannel, callback ); else { httpNotificationChannel.ConnectionStatusChanged += _onConnectionStatusChangedHandler = delegate( object sender, NotificationChannelConnectionEventArgs args ) { if( args.ConnectionStatus.Equals( ChannelConnectionStatus.Connected ) ) { ProceedRegistration( httpNotificationChannel, callback ); httpNotificationChannel.ConnectionStatusChanged -= _onConnectionStatusChangedHandler; } }; httpNotificationChannel.Open(); } if(pushNotificationsBinding != null) pushNotificationsBinding.ApplyTo( httpNotificationChannel ); httpNotificationChannel.ErrorOccurred += ( sender, args ) => callback.ErrorHandler.Invoke( new BackendlessFault( args.Message ) ); }
internal static void RegisterDevice( string channel, PushNotificationsBinding pushNotificationsBinding, AsyncCallback<string> callback ) { if( string.IsNullOrEmpty( channel ) ) throw new ArgumentNullException( "Push channel cannot be null" ); if( _currentRegistration == null || !_currentRegistration.IsRegistered() ) MakeInternalRegistration( channel, pushNotificationsBinding, callback ); else callback.ResponseHandler.Invoke( _currentRegistration.GetRegistrationId() ); }
public void RegisterDevice(string channel, BackendlessAPI.Push.PushNotificationsBinding pushNotificationsBinding = null, AsyncCallback <string> callback = null) { if (string.IsNullOrEmpty(channel)) { throw new ArgumentNullException(ExceptionMessage.NULL_CHANNEL_NAME); } RegisterDevice(new List <string> { channel }, pushNotificationsBinding, callback); }
internal static void RegisterDevice(string channel, PushNotificationsBinding pushNotificationsBinding, AsyncCallback <string> callback) { if (string.IsNullOrEmpty(channel)) { throw new ArgumentNullException("Push channel cannot be null"); } if (_currentRegistration == null || !_currentRegistration.IsRegistered()) { MakeInternalRegistration(channel, pushNotificationsBinding, callback); } else { callback.ResponseHandler.Invoke(_currentRegistration.GetRegistrationId()); } }
private static void MakeInternalRegistration(string channel, PushNotificationsBinding pushNotificationsBinding, AsyncCallback <string> callback) { var httpNotificationChannel = HttpNotificationChannel.Find(channel); if (httpNotificationChannel == null) { httpNotificationChannel = new HttpNotificationChannel(channel, Backendless.URL); httpNotificationChannel.ChannelUriUpdated += (sender, args) => ProceedRegistration(httpNotificationChannel, callback); httpNotificationChannel.Open(); } else { httpNotificationChannel.ChannelUriUpdated += (sender, args) => ProceedRegistration(httpNotificationChannel, callback); } if (pushNotificationsBinding != null) { pushNotificationsBinding.ApplyTo(httpNotificationChannel); } /* * if(httpNotificationChannel.ConnectionStatus.Equals( ChannelConnectionStatus.Connected )) * ProceedRegistration( httpNotificationChannel, callback ); * else * { * httpNotificationChannel.ConnectionStatusChanged += * _onConnectionStatusChangedHandler = delegate( object sender, NotificationChannelConnectionEventArgs args ) * { * if( args.ConnectionStatus.Equals( ChannelConnectionStatus.Connected ) ) * { * ProceedRegistration( httpNotificationChannel, callback ); * httpNotificationChannel.ConnectionStatusChanged -= _onConnectionStatusChangedHandler; * } * }; * httpNotificationChannel.Open(); * } * * if(pushNotificationsBinding != null) * pushNotificationsBinding.ApplyTo( httpNotificationChannel ); * */ httpNotificationChannel.ErrorOccurred += (sender, args) => callback.ErrorHandler.Invoke(new BackendlessFault(args.Message)); }
public void RegisterDevice(DateTime expiration, BackendlessAPI.Push.PushNotificationsBinding pushNotificationsBinding = null, AsyncCallback <string> callback = null) { RegisterDevice(null, expiration, pushNotificationsBinding, callback); }
public void RegisterDevice(List <string> channels, BackendlessAPI.Push.PushNotificationsBinding pushNotificationsBinding = null, AsyncCallback <string> callback = null) { RegisterDevice(channels, null, pushNotificationsBinding, callback); }
public void RegisterDevice(BackendlessAPI.Push.PushNotificationsBinding pushNotificationsBinding = null, AsyncCallback <string> callback = null) { RegisterDevice(DEFAULT_CHANNEL_NAME, pushNotificationsBinding, callback); }