iOS Push Notification custom format

前端 未结 3 875
無奈伤痛
無奈伤痛 2021-01-01 11:21

I\'m new to all iOS push notification domain. I have tried a basic push notification using the following code and it works perfectly. I\'m using \"using JdSoft.Apple.Apns.No

3条回答
  •  既然无缘
    2021-01-01 11:52

    I am using push sharp library.

     public static JObject CreatePayload(APNSNotification apnsNotification, object content, int Ntype)
            {
                var payload = new Dictionary();
                var aps = new Dictionary();
    
    
                if ((int)NotificationType.CONFERENCE == Ntype)
                {
                    var confNotification = new ConferenceNotification();
                    confNotification = (ConferenceNotification)content;
    
                    aps.Add("alert", confNotification.title);
                    aps.Add("subtitle", confNotification.body);
                    aps.Add("badge", confNotification.badgeCount);
    
                    payload.Add("aps", aps);
    
    
                    payload.Add("confId", confNotification.confId);
                    payload.Add("pageFormat", confNotification.pageFormat);
                    payload.Add("pageTitle", confNotification.pageTitle);
                    payload.Add("webviewURL", confNotification.webview_URL);
                    payload.Add("notificationBlastID", confNotification.notificationBlastID);
                    payload.Add("dataValue", confNotification.dataValue);
                    payload.Add("pushtype", "Events");
                }
                else if ((int)NotificationType.NEWS == Ntype)
                {
                    var newsNotification = new NewsNotification();
                    newsNotification = (NewsNotification)content;
    
                    aps.Add("alert", newsNotification.title);
                    aps.Add("subtitle", newsNotification.subtitle);
                    aps.Add("badge", newsNotification.badgeCount);
    
                    payload.Add("aps", aps);
    
                    payload.Add("articleId", newsNotification.articleId);
                    payload.Add("msgcnt", newsNotification.msgcnt);
                    payload.Add("type", newsNotification.type);
                    payload.Add("pushtype", "News");
                }
    
                return JObject.Parse(Newtonsoft.Json.JsonConvert.SerializeObject(payload));
            }
    

提交回复
热议问题