ios push推送
来源:互联网 发布:linux ping 100个包 编辑:程序博客网 时间:2024/04/29 23:21
很多关于push推送的帖子都是好久之前的了,太老了,为了方便大家能更节约时间的完成这个功能,我特意花费了5个小时整理了一份可以堪称史上最全最细致的push推送。
下面开始正文,我就不再自夸了。
首先进入开发者账号
1,新建App IDs
2,我们接下来修改刚生成的这个证书
3,接下来就要进入钥匙串生成证书了
4,这时候找到我们通过钥匙串保存的证书,最好单独放一个文件夹,这样后期做其他证书时候会更清晰,现在就可以打开刚才隐藏了的网页,然后继续往下走了。
5,这时候就可以开始一个新的块了,建一个开发者模式证书
6,网页生成证书,这个就告一段落了,我们又要有一个新的开始了。
7,打开工程项目
这是截图的代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIApplicationsharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound |UIRemoteNotificationTypeAlert];
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
{
// iOS 8 Notifications
[application registerUserNotificationSettings:[UIUserNotificationSettingssettingsForTypes:(UIUserNotificationTypeSound |UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)categories:nil]];
[application registerForRemoteNotifications];
}
else
{
// iOS < 8 Notifications 注册推送通知 推送的形式:标记,提示,声音
[application registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
}
return YES;
}
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSString *tokenStr = [NSStringstringWithFormat:@"%@",deviceToken];
tokenStr = [tokenStr stringByTrimmingCharactersInSet:[NSCharacterSetcharacterSetWithCharactersInString:@"<>"]];//将其中的<>去掉
tokenStr = [tokenStr stringByReplacingOccurrencesOfString:@" "withString:@""];//将其中的空格去掉
NSLog(@"Receive DeviceToken: %@", tokenStr);
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
NSLog(@"注册失败,无法获取设备ID,具体错误: %@", error);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
// 处理推送消息
NSLog(@"收到推送消息 userinfo:%@",userInfo);
}
- (void)application:(UIApplication *)applicationdidFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
NSLog(@"Registfail%@",error);
}
这时候就可以再次的隐藏你的工程文件了,我们要翻篇了
8,再次打开钥匙串
刚才导出的是cert.p12,接下来我们导出key.p12
当保存完这个证书时候,接着我们再翻篇
9,打开终端
输入框的内容:openssl pkcs12 -clcerts -nokeys -out cert.pem -in cert.p12
输入框的内容:openssl pkcs12 -nocerts -out key.pem -in key.p12
继续在终端输入……
输入的内容:cat cert.pem key.pem > dev.pem
这时候可以隐藏终端了,去看看文件夹里是不是有这个dev.pem了
再次打开刚才隐藏的终端
该文章完篇了,谢谢你花时间看了这么久。
- iOS 推送详解 push
- ios push推送
- iOS push 推送 总结
- Parse--iOS Push(推送通知)
- iOS - Push - 原生推送开发
- IOS Push消息推送原理及应用
- IOS Push消息推送原理及应用
- ios中push推送机智详解
- IOS 推送服务--Apple Push Notification Service
- iOS 远程推送(Push Notification)实现
- iOS开发之远程推送Push
- ios push 推送证书及合并
- iOS开发之远程推送Push
- iOS开发之远程推送Push
- 苹果推送(APNs)ios push小结
- iOS - Push - 推送的页面跳转
- Push推送
- Push推送
- adb shell input text 输入特殊字符 &
- nodejs连接mysql
- Android 常用 mimeType 表
- 19、Remove Nth Node From End of List
- Activity切换动画效果
- ios push推送
- 18 commands to monitor network bandwidth on Linux server
- 79使用相机拍照
- WebSerice学习笔记1——WebSerice基础
- hdu---1061 Rightmost Digit
- opencv 图像降噪函数
- Android 屏幕录屏,然后转为GIF图
- Map的四种遍历方法
- ArcGIS WebApp Builder 使用指南