public void Simple() { var service = new AddRegistrationService { RequestBuilder = ServerRequestBuilder.Instance }; var registration = new AddRegistrationRequest { DeviceToken = "AppleDeviceId", Tags = new List<string> {"MyTag"}, Alias = "MyAlias", Badge = 10 }; service.Execute(registration, response => Debug.WriteLine("Success"), ExceptionHandler.Handle); }
public void Tags() { var service = new AddRegistrationService { RequestBuilder = RequestBuilderHelper.Build() }; var registration = new AddRegistrationRequest { DeviceToken = RemoteSettings.AppleDeviceId, Tags = new List<string> { "bangladesh", } }; var asyncTestHelper = new AsyncTestHelper(); service.Execute(registration, x => asyncTestHelper.Callback(null), asyncTestHelper.HandleException); asyncTestHelper.Wait(); }
private void PushToCustomer(long CustomerID, string Text, long ChallengeID=0) { IPushServiceTokenRepository tokenRepo = RepoFactory.GetPushServiceTokenRepo(); AddRegistrationService reg = new AddRegistrationService { RequestBuilder = GetIOSUAProductionCredentials() }; PushService service = new PushService { RequestBuilder = GetIOSUAProductionCredentials() }; List<string> pushTokens = new List<string>(); foreach (PushServiceToken t in tokenRepo.TokensForCustomer(CustomerID)) { reg.Execute(t.Token, new Registration()); pushTokens.Add(t.Token); Trace.WriteLine("PUSH: Registering device token "+t.Token+" for customer "+CustomerID); } if (pushTokens.Count == 0) return; PushPayload payload = new PushPayload(); payload.Alert = Text; payload.Badge = "0"; Trace.WriteLine("PUSH: Pushing \"" + Text + "\" to " + pushTokens.Count.ToString()+" clients - "+pushTokens.ToString()); Dictionary<string, string> customData=null; if (ChallengeID > 0) { customData = new Dictionary<string, string>(); customData.Add("dareid", ChallengeID.ToString()); } try { PushNotification notification = new PushNotification { DeviceTokens = pushTokens, Payload = payload, CustomData=customData }; service.Execute(notification); } catch (Exception e) { Trace.WriteLine("PUSH: Exception encountered, " + e.ToString()); } }