测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | Apache 2 |
发布最后发布 | 2017年10月 |
由以下人员维护:corinne krych,Julio Cesar,Daniel Passos,Massimiliano Ziccardi。
AeroGear 统一推送服务器的 iOS 推送通知注册 SDK
这是一个小巧且实用的库,帮助 iOS 应用程序注册到 AeroGear 统一推送服务器。
项目信息 | |
---|---|
许可证 | Apache 许可证,版本 2.0 |
构建 | CocoaPods |
文档 | http://aerogear.org/ios/ |
问题跟踪器 | https://issues.jboss.org/browse/AGIOS |
邮件列表 | aerogear-users (订阅) |
aerogear-dev (订阅) |
要构建库,只需运行构建脚本
build.sh
构建脚本将生成一个包含通用静态库和框架的 buid 文件夹,源代码和文档也被打包。
push-sdk.xcodeproject 包含两个框架目标 pushsdk
,以构建从 iOS8 支持的动态框架,当运行单元测试时使用,以及 push-sdk
,用于构建从 iOS7 支持的静态框架。
注意 动态框架名称不应包含 -
符号。
您有多种方法可以将 aerogear-push-registration 库添加到您的项目中。
在构建库(请参阅“构建库”部分)后,从 aerogear-ios-push 目录运行复制命令
cp -R build/AeroGearPush-iphoneuniversal/* ../<YourProjectFolder>
转到项目导航器中的根节点,选择目标。选择构建设置,在列表中定位到头文件搜索路径设置。双击头文件搜索路径项,将弹出一个窗口。单击 + 按钮,输入以下内容
$SOURCE_ROOT/include
选择构建阶段选项卡,展开链接二进制文件与库部分,并添加 libpush-sdk-X.X.X.a
单击构建设置选项卡,定位到其他链接器标志设置,并添加 -ObjC
注意:请参阅上面的 64 位注意事项。
构建框架(请参阅“构建库”部分)后,从 aerogear-ios-push 目录运行复制命令
cp -R build/AeroGearPush-framework/AeroGearPush.framework ../<YourProjectFolder>
前往目标。在构建阶段/链接二进制与库中添加AeroGearPush.framework
#import <AeroGearPush/AeroGearPush.h>
您可以使用aerogear-push-helloworld作为使用aerogear-push-ios-registration作为框架依赖的项目示例。
注意:请参阅上面的 64 位注意事项。
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
AGDeviceRegistration *registration =
[[AGDeviceRegistration alloc] initWithServerURL:
[NSURL URLWithString:@"http://YOUR_SERVER/ag-push/"]];
[registration registerWithClientInfo:^(id<AGClientDeviceInformation> clientInfo) {
[clientInfo setDeviceToken:deviceToken];
[clientInfo setVariantID:@"YOUR IOS VARIANT ID"];
[clientInfo setVariantSecret:@"YOUR IOS VARIANT SECRET"];
// --optional config--
UIDevice *currentDevice = [UIDevice currentDevice];
[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);
}];
}
在ppDelegate.m
文件中
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
AGDeviceRegistration *registration =
[[AGDeviceRegistration alloc] init];
[registration registerWithClientInfo:^(id<AGClientDeviceInformation> clientInfo) {
[clientInfo setDeviceToken:deviceToken];
UIDevice *currentDevice = [UIDevice currentDevice];
[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库接收通知时没有额外的钩子。您可以在应用程序运行时使用现有的代理来接收远程通知,例如
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
// extract desired value from the dictionary...
}
如果您对监测推送消息如何与您的应用使用情况相关感兴趣,可以使用指标。这些指标在AeroGear统一推送服务器的控制台中显示。
- (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进行应用程序开发!
如果您发现了虫子,请在我们Jira上为我们创建一个票据,并提供一些重现步骤。