本文介绍了发送批量推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在使用c#和vb.net发送苹果和黑莓手机的推送通知,但我的应用程序一次只发送一个用户,所以我需要一个新方法向几个用户发送推送通知同时... 这里是我正在使用的代码: apple:I am using c# and vb.net to send push notifications for apple and blackberry handsets, but my app sends for only 1 user at a time, so i need to get a new method to send a push notification to several users at the same time...here is the code i'm using:apple:private void SendPushNotifications(DataTable tblToPush) { //True if you are using sandbox certificate, or false if using production string szSandbox = ""; string szFile =""; string szPassword =""; szSandbox = NGlobal.fnGetConfig("sandbox"); szFile = NGlobal.fnGetConfig("p12File"); szPassword = NGlobal.fnGetConfig("p12FilePassword"); bool sandbox = true; //dev if (szSandbox == "1") { sandbox = false; //prod } string p12File = szFile; string p12FilePassword = szPassword; string p12Filename = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, p12File); NotificationService service = new NotificationService(sandbox, p12Filename, p12FilePassword,1); service.SendRetries = 5; //5 retries before generating notificationfailed event service.ReconnectDelay = 5000; //5 seconds service.Error += new NotificationService.OnError(service_Error); service.NotificationTooLong += new NotificationService.OnNotificationTooLong(service_NotificationTooLong); service.BadDeviceToken += new NotificationService.OnBadDeviceToken(service_BadDeviceToken); service.NotificationFailed += new NotificationService.OnNotificationFailed(service_NotificationFailed); service.NotificationSuccess += new NotificationService.OnNotificationSuccess(service_NotificationSuccess); service.Connecting += new NotificationService.OnConnecting(service_Connecting); service.Connected += new NotificationService.OnConnected(service_Connected); service.Disconnected += new NotificationService.OnDisconnected(service_Disconnected); } public bool PushMessage(string testDeviceToken, string message, NotificationService service, int i, string szHiddenMessage) { var payload1 =new NotificationPayload(); //Create a new notification to send Notification alertNotification = new Notification(testDeviceToken); if (szHiddenMessage == "startAlarm") { payload1 = new NotificationPayload(message, 0, "alarm.m4a"); } else{ if (szHiddenMessage == "wipeDevice" || szHiddenMessage == "sendLocation") { payload1 = new NotificationPayload(message, 0, "Silence.m4r"); } else{ payload1 = new NotificationPayload(message, 1, "Default"); } } payload1.AddCustom("message", szHiddenMessage); var push = new Notification(testDeviceToken, payload1); } blackberry:blackberry:SyncLock lockThis If szPinCode <> "" AndAlso szPinCode <> "" Then Dim BBPushRequest As New HttpBBPushRequest(szPinCode, szMessage, szId, Me) BBPushRequest.Url = general.fnGetConfig("PUSH_URL") BBPushRequest.ApplicationID = general.fnGetConfig("PUSH_APPLICATIONID") BBPushRequest.UserName = general.fnGetConfig("PUSH_USERNAME") BBPushRequest.UserPassword = general.fnGetConfig("PUSH_USERPASSWORD") Dim clientThread As New Thread(AddressOf BBPushRequest.Run) clientThread.Start() fnIncrementCounter() bResult = True End If End SyncLock推荐答案 这篇关于发送批量推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-18 21:05