AeroGear iOS Push
这是一个方便的库,可以帮助 iOS 应用程序注册到 AeroGear 统一推送服务器。
项目信息 | |
---|---|
许可证 | Apache License, Version 2.0 |
构建 | CocoaPods |
语言 | Objective-C |
文档 | http://aerogear.org/ios/ |
问题跟踪器 | https://issues.jboss.org/browse/AGIOS |
邮件列表 | aerogear-users (订阅) |
aerogear-dev (订阅) |
目录
特性
- 在 AeroGear 统一推送服务器 上注册(通过程序和 plist)
- 向 AeroGear 统一推送服务器 发送指标
安装
CocoaPods
在您的 Podfile
中添加
pod 'AeroGearPush'
然后
pod install
以安装您的依赖项
使用方法
推送注册(编程方式)
// setup registration
AGDeviceRegistration *registration = [[AGDeviceRegistration alloc] initWithServerURL:
[NSURL URLWithString:@"http://YOUR_SERVER/ag-push/"]];
// attempt to register
[registration registerWithClientInfo:^(id <AGClientDeviceInformation> clientInfo) {
// setup configuration
[clientInfo setDeviceToken:deviceToken];
[clientInfo setVariantID:@"YOUR IOS VARIANT ID"];
[clientInfo setVariantSecret:@"YOUR IOS VARIANT SECRET"];
// apply the token, to identify THIS device
UIDevice *currentDevice = [UIDevice currentDevice];
// set some 'useful' hardware information params
[clientInfo setOperatingSystem:[currentDevice systemName]];
[clientInfo setOsVersion:[currentDevice systemVersion]];
[clientInfo setDeviceType:[currentDevice model]];
} success:^() {
NSLog(@"UnifiedPush Server registration worked");
} failure:^(NSError *error) {
NSLog(@"UnifiedPush Server registration Error: %@", error);
}];
推送注册(plist文件)
// setup registration
AGDeviceRegistration *registration = [[AGDeviceRegistration alloc] init];
// attempt to register
[registration registerWithClientInfo:^(id <AGClientDeviceInformation> clientInfo) {
// setup configuration
[clientInfo setDeviceToken:deviceToken];
// apply the token, to identify THIS device
UIDevice *currentDevice = [UIDevice currentDevice];
// set some 'useful' hardware information params
[clientInfo setOperatingSystem:[currentDevice systemName]];
[clientInfo setOsVersion:[currentDevice systemVersion]];
[clientInfo setDeviceType:[currentDevice model]];
} success:^() {
NSLog(@"UnifiedPush Server registration worked");
} failure:^(NSError *error) {
NSLog(@"UnifiedPush Server registration Error: %@", error);
}];
在您的应用程序info.plist中添加以下属性
<plist version="1.0">
<dict>
<key>serverURL</key>
<string><# URL of the running AeroGear UnifiedPush Server #></string>
<key>variantID</key>
<string><# Variant Id #></string>
<key>variantSecret</key>
<string><# Variant Secret #></string>
</dict>
</plist>
注意:如果您的UPS服务器安装使用自签名证书,您可以在我们的故障排除页面中找到一个快速解决方案,以及如何在您的iOS生产应用程序中正确启用它的更多信息链接。
推送分析
如果您对监控推送消息与您的应用程序使用情况之间的关系感兴趣,可以使用指标。这些指标显示在AeroGear UnifiedPush Server的控制台中。
应用启动时的指标
- (BOOL) application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[AGPushAnalytics sendMetricsWhenAppLaunched:launchOptions];
return YES;
}
当应用从后台被带到前台时的指标
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
[AGPushAnalytics sendMetricsWhenAppAwoken:application.applicationState userInfo:userInfo];
}
文档
关于更多详情,请咨询我们的文档。
开发
如果你想要帮助开发AeroGear,你可以加入我们的开发者邮件列表,加入Freenode上的#aerogear,或者在Twitter @aerogears上给我们留言。
还可以阅读贡献指南
有问题吗?
加入我们的用户邮件列表,有任何问题或寻求帮助!我们非常希望你喜欢使用AeroGear进行应用开发!
发现了bug?
如果你发现了bug,请在我们Jira上为我们创建一个提单,并附带一些复现步骤。