一、准备工作
1、一台mac
2、一部iphone
3、苹果开发者认证的账号
二、开始
1、用mac申请一个CertificateSigningRequest.certSigningRequest,这个步骤百度一大堆。
2、苹果开发者中心管理后台,新建app,勾选apns服务,第一个是开发模式,第二个是产品模式,根据提示可以得到.cer文件,
mac上双击,加入秘钥管理器中,再右键导出p12文件,这个文件是个推平台要用的。
3、新建证书,根据提示一路走,最后得到一个.cer文件,mac上双击,加入密钥管理器,再右键导出p12文件,这是发布app要用的。这个文件要和上边那个对应,都为开发模式或都为产品模式。
4、属性文件,新增,根据提示操作就行了,最后得到.mobileprovision文件,发布app使用的。
public static string APNsPushToSingle(string title,string content,string token)
{
APNTemplate template = new APNTemplate();
APNPayload apnpayload = new APNPayload();
DictionaryAlertMsg alertMsg = new DictionaryAlertMsg();
alertMsg.Body = content; //通知文本消息字符串
alertMsg.ActionLocKey = "";
alertMsg.LocKey = "";
alertMsg.addLocArg("");
alertMsg.LaunchImage = "";//指定启动界面图片名
//IOS8.2支持字段
alertMsg.Title = title; //通知标题
alertMsg.TitleLocKey = "";
alertMsg.addTitleLocArg("");
apnpayload.AlertMsg = alertMsg;
apnpayload.Badge = 1;//应用icon上显示的数字
apnpayload.ContentAvailable = 1;//推送直接带有透传数据
apnpayload.Category = "";
apnpayload.Sound = "";//通知铃声文件名
apnpayload.addCustomMsg("", "");//增加自定义的数据
template.setAPNInfo(apnpayload);
IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);
/*单个用户推送接口*/
SingleMessage Singlemessage = new SingleMessage();
Singlemessage.Data = template;
String pushResult = push.pushAPNMessageToSingle(APPID, token, Singlemessage);
Console.Out.WriteLine(pushResult);
return pushResult;
}
{"taskId":"OSAPNS-0222_sWuNF6FsJE7ilfijXLv0D6","result":"ok"}
iOS集成个推推送服务指南
本文档介绍了如何在iOS环境中结合个推实现推送服务。首先,你需要准备一台Mac、一部iPhone和苹果开发者认证的账号。接着,通过Mac生成CertificateSigningRequest文件,并在苹果开发者中心创建App并启用APNs服务,获取.cer文件并导出p12格式用于个推平台。然后,创建发布证书,同样导出p12文件以备发布应用。最后,新建属性文件生成.mobileprovision,用于发布应用程序。确保所有证书和文件的模式一致,即可完成配置。
1万+

被折叠的 条评论
为什么被折叠?



