public async Task UnregisterAsync() { await Task.Run(() => { try { // Unregister method is blocking, never call it on main thread Gcm.Unregister(); IsRegistered = false; RegistrationId = string.Empty; if (Unregistered != null) { Unregistered(this, EventArgs.Empty); } } catch (Java.IO.IOException e) { if (Error != null) { Error(this, new NotificationErrorEventArgs { Message = e.Message }); } } }).ConfigureAwait(false); }
public async Task RegisterAsync() { if (!CheckPlayServices()) { return; } await Task.Run(() => { try { if (Configuration.SenderIds == null || !Configuration.SenderIds.Any()) { throw new InvalidOperationException("Cannot register without any SenderId's"); } // Register method is blocking, never call it on main thread RegistrationId = Gcm.Register(Configuration.SenderIds); IsRegistered = true; if (Registered != null) { Registered(this, new DidRegisterForNotificationsEventArgs { RegistrationId = RegistrationId }); } } catch (Java.IO.IOException e) { if (Error != null) { Error(this, new NotificationErrorEventArgs { Message = e.Message }); } } }).ConfigureAwait(false); }
//Funciton to load private string insertUpdateData(Gcm data, string path) { try { var db = new SQLiteConnection(path); if (db.Insert(data) != 0) db.Update(data); return "Single data file inserted or updated"; } catch (SQLiteException ex) { return ex.Message; } }