public AppleNotification(string deviceToken, AppleNotificationPayload payload) { DeviceToken = new DeviceToken(deviceToken); Payload = payload; Identifier = GetNextIdentifier(); }
public AppleNotification(DeviceToken deviceToken) { DeviceToken = deviceToken; Payload = new AppleNotificationPayload(); Identifier = GetNextIdentifier(); }
public static void Notify(DeviceToken deviceToken, string message) { //Create our push services broker var push = new PushBroker(); push.OnChannelException += PushOnOnChannelException; push.OnNotificationFailed += PushOnOnNotificationFailed; push.OnNotificationSent += PushOnOnNotificationSent; push.OnServiceException += PushOnOnServiceException; if (deviceToken.Device.Contains("iOS")) { //Registering the Apple Service and sending an iOS Notification var appleCert = File.ReadAllBytes("C:\\Certs\\Certificate.p12"); push.RegisterAppleService(new ApplePushChannelSettings(false, appleCert, "password")); push.QueueNotification(new AppleNotification() .ForDeviceToken(deviceToken.Token) .WithAlert(message) .WithBadge(1) .WithSound("sound.caf")); } else if (deviceToken.Device.Contains("Android")) { //Registering the GCM Service and sending an Android Notification push.RegisterGcmService(new GcmPushChannelSettings("AIzaSyD8GfrF6Sgcw6WQRSVCij110rHuUmm4Zus")); push.QueueNotification(new GcmNotification().ForDeviceRegistrationId(deviceToken.Token) .WithJson("{\"alert\":\"" + message + "\",\"to\":\"/topics/global\",\"badge\":1,\"sound\":\"sound.caf\"}")); } //else if (deviceToken.Device.Contains("windows")) //{ // push.QueueNotification(new WindowsPhoneToastNotification() // .ForEndpointUri(new Uri(model.ChannelURI)) // .ForOSVersion(WindowsPhoneDeviceOSVersion.Eight) // .WithBatchingInterval(BatchingInterval.Immediate) // .WithNavigatePath(model.NavigatePath) // .WithText1("Datadruid Push") // .WithText2(message)); //} push.StopAllServices(); }