标签:ons key res amp 内容 name androi ati form
// 推送到IOS平台
/// <param name="registeration_id">注册的设备ID</param>
/// <param name="content">推送的内容</param>
private bool SendPushToIos(string registeration_id, string content)
{
if (string.IsNullOrEmpty(registeration_id))
return false;
if (string.IsNullOrEmpty(appKey) || string.IsNullOrEmpty(masterSecret))
return false;
JPushClient client = new JPushClient(appKey, masterSecret);
PushPayload pushPayload = new PushPayload();
pushPayload.options.apns_production = apns_production;
pushPayload.platform = Platform.ios();
pushPayload.audience = Audience.s_registrationId(registeration_id);
pushPayload.notification = Notification.ios(content);
//发送请求
var result = client.SendPush(pushPayload);
if (result != null && result.msg_id > 0)
return true;
else
return false;
}
// 推送到Android平台
/// <param name="registeration_id">注册的设备ID</param>
/// <param name="content">推送的内容</param>
private bool SendPushToAndroid(string registeration_id, string content)
{
if (string.IsNullOrEmpty(registeration_id))
return false;
if (string.IsNullOrEmpty(appKey) || string.IsNullOrEmpty(masterSecret))
return false;
JPushClient client = new JPushClient(appKey, masterSecret);
PushPayload pushPayload = new PushPayload();
pushPayload.options.apns_production = apns_production;
pushPayload.platform = Platform.android();
pushPayload.audience = Audience.s_registrationId(registeration_id);
pushPayload.notification = Notification.android(content,"易钱宝");
//发送请求
var result = client.SendPush(pushPayload);
if (result != null && result.msg_id > 0)
return true;
else
return false;
}
//推送消息
public bool SendPush(PlatformEnum platform, string registeration_id, string content)
{
int platform_val = (int)platform;
if (platform_val == 10)
return SendPushToIos(registeration_id, content);
else if (platform_val == 20)
return SendPushToAndroid(registeration_id, content);
else
return false;
}
// 推送平台枚举
public enum PlatformEnum
{
/// <summary>
/// IOS
/// </summary>
ios = 10,
/// <summary>
/// Android
/// </summary>
android = 20
}
标签:ons key res amp 内容 name androi ati form
原文地址:http://www.cnblogs.com/Alwayswantmore/p/Push_1.html