Push notification的实现过程
1. 创建SSL证书
首先需要需要创建一个App ID以及关联的SSL证书。有了证书,解析服务器才能找到你的App ID,继而将通知推送到你的应用。
首先创建一个证书请求文件:
a. 在mac上运行钥匙串访问(keychain)
b. 选择钥匙串访问>证书助理>从证书颁发机构中请求一个证书
c. 输入你的名字和邮件地址,CA邮件地址默认就可以,不要试图去进行任何改动。
d. 选择“保存到硬盘”,这样.certSigningRequest的文件生成了。
e. 操作界面如下所示:
然后创建APP ID:
a. 登陆网站Apple Developer Member Center并进入iOS Provisioning Portal。
b. 从左边栏里点击App IDs。
c. 选择New App ID,然后创建一个新的App ID。一定要确保Bundle Identifier一栏中没有星号。
d. 在你的App ID下面找到Configure,选中。
e. 将“Enable for Apple Push Notification service”勾选上,然后点击Development Push SSL Certificate下面的Configure,然后会出现Apple Push Notification service SSL Certificate Assistant设置向导。
f. 点击Continue继续,然后点击Choose File,选中刚创建见的.certSigningRequest文件。
g. 点击Generate开始生成,然后点击Download下载生成的SSL证书。
h. 通过keychain程序来安装下载好的SSL证书。
i. 接着在“我的证书”选项先面,找到你刚才安装名称形如“Apple Development IOS Push Services: xxx”的证书。
j. 双击证书,选择“导出”,导出后的文件后缀名为.p12。这个时候千万注意!出现密码提示的时候一定不要添任何东西。
至此SSL证书创建完成。
2. 创建Provisioning Profile
a. 在 ios provisioning portal中选择provisioning
b. 点击New profile
c. 按照要求填写profile name,certificate,APP ID(刚才创建的app id),devices
d. 下载生成的provisioning profile
e. 双击安装。
至此前期的准备工作完成,此时你应该有.certSigningRequest .cer .p12 .mobileprovision四个文件,现在需要编写代码了。
首先需要编写客户端的代码
a. 需要在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法中添加[application registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound];
代码片段。
b.需要继承以下3个方法。
/**接受后台推送的消息*/
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
/**此处要对返回的信息做提示的处理,振动,alert提示*/
}
/**注册成功获取deviceToken*/
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
/**此处需要将生成的deviceToken传到服务端。*/
}
/**注册失败*/
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{
}
服务端这里我们采用的是网上提供的:pushmeBaby。服务端做的事情包括收集deviceToken,推出消息。需要一个APNs的回调service?详见https://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html
这个文档。有详细的描述。{"aps":{"alert":"This is some fancy message.","badge":2 ,"sound" : "ping1.caf"}}
分享到:
相关推荐
完整的介绍了如何ios push notification的使用过程。包括工程的编写,和server的端的介绍。希望对大家会有帮助。
NULL 博文链接:https://wang-peng1.iteye.com/blog/1741757
PHP代码发送IOS推送消息 PUSH IOS NOTIFICATION
主要介绍了IOS 打包出现Missing Push Notification Entitlement 问题解决方案的相关资料,需要的朋友可以参考下
npm install --save react-native-push-notification react-native link NOTE: For Android, you will still have to manually update the AndroidManifest.xml (as below) in order to use Scheduled Notifications...
push-notification-server, 向iOS或者Android设备发送推送通知的服务器代码 推送通知服务器这可以用于向iOS或者Android设备发送推送通知。 Android推送通知SERVER_KEY - 如果你没有 SERVER_KEY,请使用本教程中的...
@ react-native-community / push-notification-ios 对iOS的React Native Push Notification API 通知有行动使用TextInput动作入门安装yarn add @react-native-community/push-notification-ios链接React Native v...
Laravel开发-laravel-push-notification Laravel 5软件包,用于向Android和iOS设备发送推送通知。与Witty的相同,增加了对Laravel 5.2的支持
适用于Apple的Azure Notification Hubs SDK提供了在macOS和iOS(包括tvOS,watchOS和Mac Catalyst等平台)上注册设备并接收推送通知的功能。 入门 可以通过Cocoapods,Carthage,Swift Package Manager或通过手动将...
通知您可以加载任何闪电页面的简单组件,以显示当前记录或父记录中的字段值。 您可以在组件内设置颜色和标题,还可以使用本机Salesforce配置确定何时应显示以及在谁处显示。版本控制1.0.1 包括解锁的软件包版本配置...
SmartPush,一款IOS苹果推送测试程序,Mac OS下的apps工具APP SmartPush,iOS Push Notification Debug App 基于PushMeBaby,https://github.com/stefanhafeneger/PushMeBaby 修改,感谢作者
APNS 是Apple Push Notification Service(Apple Push服务器)的缩写,下文统一使用该缩写。 因 此,整个过程可以分为三个阶段,下面用大家常用的聊天客户端BeejiveIM来说明。(BeejiveIM是一款支持多账户登录的...
npm install -g push-notification-test-tool 设置 要设置工具运行,请执行以下操作: pushtester setup --androidSenderAPIKey YOUR_API_KEY --bundle YOUR_BUNDLE_ID --iosCert ABSOLUTE_PATH_TO_p8 --iosTeamId...
对于iOS,正在使用Apple Push Notification(APN)和对于Android,则使用Google Cloud Messaging(GCM)。如何执行(iOS)? 将push_notification.sql转储到数据库中。 更新webservice / index.php第12行中的数据库...
Master push notifications on iOS! Push notifications may seem simple and straightforward at first since almost everyone is familiar with them; however, knowing how and when to use them in practice ...
add the import at the topimport flutter_push_notification@UIApplicationMain@objc class AppDelegate: FlutterAppDelegate { ... // 2. inside AppDelegate, forward these two functions to our plugin ...
离子推送通知应用安装克隆仓库git clone https://github.com/jaffyadhav/ionic-push-notification.git 下载依赖项ionic state restore 注意:您的cordova版本必须> = 5.2.0才能正常工作创建登录至ionic.io ionic ...
= 2.1.0 > = 0.33变更日志可从以下版本3.1.3获得 : 安装NPM npm install --save react-native-push-notification 纱yarn add react-native-push-notification 注意:如果您以iOS为目标,则还需要遵循的因为此软件包...
一个bash脚本,通过Apple push Notification service (APNs)发送iOS推送通知- tsif/pu.sh-源码