.net Aurora Push

/// <Summary>
/// application identification: Aurora push username (equipment)
/// </ Summary>
Private Readonly String ConfigurationManager.AppSettings the AppKey = [ "the AppKey"];
/// <Summary>
/// Aurora push password (apparatus)
/// </ Summary>
Private Readonly String MasterSecret ConfigurationManager.AppSettings = [ "MasterSecret"];
/// <Summary>
/// test Aurora push
/// </ Summary>
/// <param name = "model"> parameters </ param>
/// <Returns> </ Returns>
[HttpPost]
[the Route ( "API / Device / Jpush / TestJpush /")]
public TestJpushResult TestJpush ([FromBody] Model TestJpushModels )
{

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. Push the assembly references Aurora

2. In the first set the alias information server Aurora

Guess you like

Origin www.cnblogs.com/tfeblog/p/11355831.html