zoukankan      html  css  js  c++  java
  • .net 极光推送

    /// <summary>
    /// 应用标识:极光推送的用户名(设备)
    /// </summary>
    private readonly string AppKey = ConfigurationManager.AppSettings["AppKey"];
    /// <summary>
    /// 极光推送的密码(设备)
    /// </summary>
    private readonly string MasterSecret = ConfigurationManager.AppSettings["MasterSecret"];
    /// <summary>
    /// 测试极光推送
    /// </summary>
    /// <param name="model">参数</param>
    /// <returns></returns>
    [HttpPost]
    [Route("api/Device/Jpush/TestJpush/")]
    public TestJpushResult TestJpush([FromBody]TestJpushModels model)
    {

    List<JpushModels> list = new List<JpushModels>();
    JpushModels jModel = new JpushModels();
    jModel.productid = 1;
    jModel.price = "12";
    JpushModels jModel1 = new JpushModels();
    jModel1.productid = 2;
    jModel1.price = "13";
    JpushModels jModel2 = new JpushModels();
    jModel2.productid = 3;
    jModel2.price = "14";
    list.Add(jModel);
    list.Add(jModel1);
    list.Add(jModel2);
    try
    {
    JPushClient client = new JPushClient(AppKey, MasterSecret);
    PushPayload pushPayload_alias = new PushPayload()
    {
    platform = Platform.android()
    };

    string[] alias = new string[] { model.code };
    pushPayload_alias.audience = Audience.s_alias(alias);//别名

    //通知
    //var notification = new Notification();
    //notification.AndroidNotification = new AndroidNotification().setAlert(model.title).AddExtra("action1", "101");
    //pushPayload_alias.notification = notification;
    string data = JsonConvert.SerializeObject(list);
    //自定义
    pushPayload_alias.message = Message.content(model.content).AddExtras("action1", "100").AddExtras("data", data).setTitle(model.title);
    bool b = client.SendPush(pushPayload_alias).isResultOK();
    if (b)
    {
    return new TestJpushResult { ResCode = ResCode.Ok, ResMsg = "成功" };
    }
    else
    {
    return new TestJpushResult { ResCode = ResCode.Ok, ResMsg = "失败" };
    }
    }
    catch (Exception ex)
    {
    return new TestJpushResult { ResCode = ResCode.Fail, ResMsg = ex.ToString()};
    }
    }

    1.引用极光推送程序集

    2.在极光服务器先设置别名信息

  • 相关阅读:
    按钮组件如何处理点击事件(将原生事件绑定到自定义组件)
    一个简单的transition动画
    根据路由记录(利用matched)动态生成面包屑导航
    assets和static的异同
    Ceph集群概念以及部署
    腾讯质量效能提升最佳实践:智能自动化测试探索和建设
    腾讯WeTest压测大师通过中国计量科学研究院测试认证,获国家级权威认可
    新办公司每年费用
    2
    Leetcode刷题第三题 无重复字符的最长子串
  • 原文地址:https://www.cnblogs.com/tfeblog/p/11355831.html
Copyright © 2011-2022 走看看