北鸣对接T+畅捷通,看板API
yl
2023-11-20 f84de3e390ddb9f637342f16e758da4cbef5216e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using com.gexin.rp.sdk.dto;
using com.igetui.api.openservice;
using com.igetui.api.openservice.igetui;
using com.igetui.api.openservice.igetui.template;
using com.igetui.api.openservice.igetui.template.notify;
using com.igetui.api.openservice.payload;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
 
namespace VueWebApi.Tools
{
    /// <summary>
    /// 个推
    /// </summary>
    public class GeTuiMessage
    {
 
        public const string HOST = "http://sdk.open.api.igexin.com/apiex.htm";
        public const string APPID = "";
        public const string APPKEY = "";
        public const string AppSecret = "";
        public const string MASTERSECRET = "";
 
        /// <summary>
        /// 推送一批用户
        /// </summary>
        /// <param name="title">标题 例如  抢购会</param>
        /// <param name="content">内容 例如 华为Mate30 5G抢购 </param>
        /// <param name="url">APP跳转地址 商品单页 活动页 或者其它页面</param>
        /// <param name="cids">数据库pushclientid字段集合</param> 
        /// <returns>推送结果</returns>
        public static string pushMessageToList(string title, string content, string url, string[] cids)
        {
            IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);
            ListMessage message = new ListMessage();
            NotificationTemplate template = NotificationTemplateAndroidiOS(title, content, url);
            message.IsOffline = true;
            message.OfflineExpireTime = 1000 * 3600 * 12;
            message.Data = template;
            message.PushNetWorkType = 0;
            List<com.igetui.api.openservice.igetui.Target> targetList = new List<com.igetui.api.openservice.igetui.Target>();
 
            for (int i = 0; i < cids.Length; i++)
            {
                com.igetui.api.openservice.igetui.Target target1 = new com.igetui.api.openservice.igetui.Target();
                target1.appId = APPID;
                target1.clientId = cids[i];
                targetList.Add(target1);
            }
            String contentId = push.getContentId(message);
            String pushResult = push.pushMessageToList(contentId, targetList);
            return pushResult;
        }
 
        /// <summary>
        /// 模版一
        /// </summary>
        /// <param name="title">标题</param>
        /// <param name="content">内容</param>
        /// <param name="url">链接 APP中要跳转的页面</param>
        /// <returns></returns>
        public static NotificationTemplate NotificationTemplateAndroidiOS(string title, string content, string url)
        {
            NotificationTemplate template = new NotificationTemplate();
            template.AppId = APPID;
            template.AppKey = APPKEY;
            template.Title = title;  //通知栏标题
            template.Text = content; //通知栏内容
            template.Logo = "";      //通知栏显示本地图片
            template.LogoURL = "";   //通知栏显示网络图标
            template.TransmissionType = 1;//通知栏显示网络图标
            template.TransmissionContent = "{\"url\":\"" + url + "\"}"; //透传内容
            template.IsRing = true;   //接收到消息是否响铃,true:响铃 false:不响铃
            template.IsVibrate = true;  //接收到消息是否响铃,true:响铃 false:不响铃
            template.IsClearable = true; //接收到消息是否可清除,true:可清除 false:不可清除
 
            //安卓透传厂商通道
            Notify notify = new Notify();
            notify.Content = title;
            notify.Title = content;
            string newUrl = "{\"url\":\"" + url + "\"}";
            notify.Intent = $"intent:#Intent;action=android.intent.action.oppopush;launchFlags=0x14000000;component=您的安卓包名/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title={title};S.content={content};S.payload={newUrl};end";
            notify.Type = NotifyInfo.Types.Type._intent;
            template.set3rdNotifyInfo(notify);
 
 
            //苹果透传配置
            APNPayload apnpayload = new APNPayload();
            DictionaryAlertMsg alertMsg = new DictionaryAlertMsg();
            // IOS 的body用这个
            alertMsg.Body = content;
            alertMsg.ActionLocKey = "ActionLocKey";
            alertMsg.LocKey = "LocKey";
            alertMsg.addLocArg("LocArg");
            alertMsg.LaunchImage = "LaunchImage";
            //iOS8.2支持字段
            alertMsg.Title = title;
            alertMsg.TitleLocKey = "TitleLocKey";
            alertMsg.addTitleLocArg("TitleLocArg");
 
            apnpayload.AlertMsg = alertMsg;
            //apnpayload.Badge = 0  +1;
            apnpayload.ContentAvailable = 0;
            apnpayload.Sound = "default";
            apnpayload.addCustomMsg("payload", "{\"url\":\"" + url + "\"}");
 
            template.setAPNInfo(apnpayload);
 
 
 
            string begin = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string end = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss");
            template.setDuration(begin, end);
            return template;
        }
    }
}