由 AfterPush 提供
当前 SDK 版本:v1.0
AfterPush是为所有 iOS 和 Android 开发者提供推送通知服务。
版本 1.0
1) 从 Apple 开发者那里获取 p12
遵循此指南为沙盒和生产环境创建证书,别忘了在您的应用 ID 上启用推送通知。
apns-dev-cert.p12
apns-dev-key.12
apns-pro-cert.p12
apns-pro-key.12
2) 将 p12 转换为 PEM 格式
openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12
openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12
openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem
cat apns-dev-cert.pem apns-dev-key-noenc.pem > apns-dev.pem
openssl pkcs12 -clcerts -nokeys -out apns-pro-cert.pem -in apns-pro-cert.p12
openssl pkcs12 -nocerts -out apns-pro-key.pem -in apns-pro-key.p12
openssl rsa -in apns-pro-key.pem -out apns-pro-key-noenc.pem
cat apns-pro-cert.pem apns-pro-key-noenc.pem > apns-pro.pem
3) 在 AfterPush 上注册账户
4) 创建您的应用并上传 pem 文件。
5) 获取您的应用密钥
6) 实现 SDK
将其添加到 Podfile 文件。
Pod 'AfterPushSDK', '~>0.0.8'
下载 AfterPushSDK.h
和 libAfterPushSDK.a
并将其添加到您的项目中,包括两个框架:CoreLocation.framework CoreTelephony.framework
7) 修改您的 AppDelegate.m
AppDelegate.m
并包含 #import "AfterPushSDK.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[[AfterPushSDK sharedInstance] initWithAppKey:@"YOUR_APP_KEY"];
#ifdef __IPHONE_8_0
//Right, that is the point
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge
|UIRemoteNotificationTypeSound
|UIRemoteNotificationTypeAlert) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
#else
//register to receive notifications
UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert |UIRemoteNotificationTypeSound;
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];
#endif
}
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[[AfterPushSDK sharedInstance] registerDeviceToken:deviceToken];
}
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo {
[[AfterPushSDK sharedInstance] notificationHandler:userInfo];
}
如SDK有任何问题,请将您的反馈发送至邮箱[email protected],这对我们非常重要。