public static void NotifyIOSUser(string token, string message, NotificationType type) { /// /Fluent construction of an iOS notification ////IMPORTANT: For iOS you MUST MUST MUST use your own DeviceToken here that gets generated within your iOS app itself when the Application Delegate //// for registered for remote notifications is called, and the device token is passed back to you //------------------------- // APPLE NOTIFICATIONS //------------------------- //Configure and start Apple APNS // IMPORTANT: Make sure you use the right Push certificate. Apple allows you to //generate one for connecting to Sandbox, and one for connecting to Production. You must // use the right one, to match the provisioning profile you build your // app with! var appleCert = File.ReadAllBytes(HostingEnvironment.MapPath(APNSCerticateFile)); //IMPORTANT: If you are using a Development provisioning Profile, you must use // the Sandbox push notification server // (so you would leave the first arg in the ctor of ApplePushChannelSettings as // 'false') // If you are using an AdHoc or AppStore provisioning profile, you must use the //Production push notification server // (so you would change the first arg in the ctor of ApplePushChannelSettings to //'true') var payLoad = new AppleNotificationPayload(); payLoad.AddCustom("NotificationType", NotificationType.MessageAlert); payLoad.AddCustom("Badge", 7); payLoad.AddCustom("DeviceID", token); PushBroker.QueueNotification(new AppleNotification(token, payLoad) //the recipient device id .WithAlert(message) //the message .WithBadge(7) .WithCategory(type.ToString()) .WithSound("sound.caf") ); }
public static AppleNotification WithPasskitUpdate(this AppleNotification n) { var payLoad = new AppleNotificationPayload(); payLoad.AddCustom("aps", string.Empty); n.Payload = payLoad; return(n); }
public void NotifyIOSUserCustom(string token, string message, NotificationType type, IOSNOtifcationModel requestModel) { /// /Fluent construction of an iOS notification ////IMPORTANT: For iOS you MUST MUST MUST use your own DeviceToken here that gets generated within your iOS app itself when the Application Delegate //// for registered for remote notifications is called, and the device token is passed back to you //------------------------- // APPLE NOTIFICATIONS //------------------------- //Configure and start Apple APNS // IMPORTANT: Make sure you use the right Push certificate. Apple allows you to //generate one for connecting to Sandbox, and one for connecting to Production. You must // use the right one, to match the provisioning profile you build your // app with! var appleCert = File.ReadAllBytes(HostingEnvironment.MapPath(APNSCerticateFile)); //IMPORTANT: If you are using a Development provisioning Profile, you must use // the Sandbox push notification server // (so you would leave the first arg in the ctor of ApplePushChannelSettings as // 'false') // If you are using an AdHoc or AppStore provisioning profile, you must use the //Production push notification server // (so you would change the first arg in the ctor of ApplePushChannelSettings to //'true') var payLoad = new AppleNotificationPayload(); payLoad.AddCustom("NotificationType", requestModel.Request.NotificationType); payLoad.AddCustom("SenderName", requestModel.Request.SenderName); payLoad.AddCustom("Badge", requestModel.Request.Badge); payLoad.AddCustom("SenderID", requestModel.Request.SenderID); payLoad.AddCustom("Message", requestModel.Request.Message); payLoad.AddCustom("DeviceType", requestModel.DeviceModel.DeviceType); payLoad.AddCustom("ExpertResponse", requestModel.Request.ExpertResponse); payLoad.AddCustom("DeviceToken", requestModel.DeviceModel.DeviceToken); payLoad.AddCustom("WorkOrderScopeID", requestModel.Request.WorkOrderScopeID); payLoad.AddCustom("ExpertID", requestModel.Request.ExpertID); payLoad.AddCustom("ReceiverROle", requestModel.Request.ReceiverRole); if (_pushBroker == null) { Configure(); } //_pushBroker = new PushBroker(); _pushBroker.RegisterAppleService(new ApplePushChannelSettings(true, appleCert, APNSCerticateFilePassword, true)); _pushBroker.QueueNotification(new AppleNotification(token, payLoad) //the recipient device id .WithAlert(message) //the message .WithBadge(requestModel.Request.Badge) .WithCategory(type.ToString()) .WithSound("sound.caf") ); }