private async void OneSignalCallback(string playerId, string pushToken) { OneSignal.Current.SendTag("username", AppSettings.User.Login); OneSignal.Current.SendTag("player_id", playerId); if (string.IsNullOrEmpty(AppSettings.User.PushesPlayerId) || !AppSettings.User.PushesPlayerId.Equals(playerId)) { var model = new PushNotificationsModel(AppSettings.User.UserInfo, playerId, true) { Subscriptions = PushSettings.All.FlagToStringList() }; var response = await BasePresenter.TrySubscribeForPushes(model); if (response.IsSuccess) { AppSettings.User.PushesPlayerId = playerId; } } }
private async Task SavePushSettings() { if (AppSettings.User.PushSettings == PushSettings) { return; } var model = new PushNotificationsModel(AppSettings.User.UserInfo, true) { Subscriptions = PushSettings.FlagToStringList() }; var resp = await _presenter.TrySubscribeForPushes(model); if (resp.IsSuccess) { AppSettings.User.PushSettings = PushSettings; } }
private async void PushesOnClick(object sender) { var model = new PushNotificationsModel(AppSettings.User.UserInfo, !UserIsWatched) { WatchedUser = Username }; var response = await BasePresenter.TrySubscribeForPushes(model); if (response.IsSuccess) { if (UserIsWatched) { AppSettings.User.WatchedUsers.Remove(Username); } else { AppSettings.User.WatchedUsers.Add(Username); } } }
public async Task <OperationResult <object> > SubscribeForPushes(PushNotificationsModel model, CancellationToken ct) { var trxResp = await _ditchClient.GetVerifyTransaction(model, ct); if (!trxResp.IsSuccess) { return(new OperationResult <object>(trxResp.Exception)); } model.VerifyTransaction = JsonConvert.DeserializeObject <JObject>(trxResp.Result); var results = Validate(model); if (results != null) { return(new OperationResult <object>(results)); } var endpoint = $"{BaseUrl}/{GatewayVersion.V1P1}/{(model.Subscribe ? "subscribe" : "unsubscribe")}"; return(await HttpClient.Put <object, PushNotificationsModel>(endpoint, model, ct)); }
public async Task <OperationResult <object> > SubscribeForPushes(PushNotificationsModel model, CancellationToken ct) { var trxResp = await _ditchClient.GetVerifyTransaction(model, ct); if (!trxResp.IsSuccess) { return(new OperationResult <object>(trxResp.Error)); } model.VerifyTransaction = trxResp.Result; var results = Validate(model); if (results.Any()) { return(new OperationResult <object>(new ValidationError(results))); } var endpoint = $"{GatewayVersion.V1P1}/{(model.Subscribe ? "subscribe" : "unsubscribe")}"; return(await Gateway.Post <object, PushNotificationsModel>(endpoint, model, ct)); }
private async Task SavePushSettings() { if (AppSettings.User.PushSettings == PushSettings) { return; } var model = new PushNotificationsModel(AppSettings.User.UserInfo, true); model.Subscriptions = PushSettings.FlagToStringList(); var resp = await BasePresenter.TrySubscribeForPushes(model); if (resp.IsSuccess) { AppSettings.User.PushSettings = PushSettings; } else { this.ShowAlert(resp.Error); } }
private async Task SavePushSettings() { if (_currentUser.PushSettings == PushSettings) { return; } var model = new PushNotificationsModel(_currentUser, true) { Subscriptions = PushSettings.FlagToStringList() }; var resp = await Presenter.TrySubscribeForPushes(model); if (resp.IsSuccess) { _currentUser.PushSettings = PushSettings; AppSettings.DataProvider.Update(_currentUser); } else { this.ShowAlert(resp.Exception); } }
public static async Task <OperationResult <object> > TrySubscribeForPushes(PushNotificationsModel model) { return(await TryRunTask <PushNotificationsModel, object>(Api.SubscribeForPushes, CancellationToken.None, model)); }
private async Task <ErrorBase> SubscribeForPushes(PushNotificationsModel model, CancellationToken ct) { var response = await Api.SubscribeForPushes(model, OnDisposeCts.Token); return(response.Error); }
private async Task <ErrorBase> TrySubscribeForPushes(PushNotificationsModel model) { var error = await TryRunTask(SubscribeForPushes, OnDisposeCts.Token, model); return(error); }
public async Task <ErrorBase> TrySubscribeForPushes(PushSubscriptionAction action, string playerId, string watchedUser) { var model = new PushNotificationsModel(User.UserInfo, playerId, watchedUser, action == PushSubscriptionAction.Subscribe); return(await TrySubscribeForPushes(model)); }