#iOS集成AWS整理PushNotification ##集成AWS ###AWS官网连接 案例中是Swift版本,Demo提供了OC版本的集成 1.Profile 中配置AWS SDK 1 2 3 4 5 6 7 8 9 platform :ios, '9.0' target :'YOUR-APP-NAME' do use_frameworks! pod 'AW
#iOS集成AWS整理PushNotification
##集成AWS
###AWS官网连接
案例中是Swift版本,Demo提供了OC版本的集成
1.Profile 中配置AWS SDK
运行
import AWSCore
import AWSPinpoint
import AWSMobileClient
lass AppDelegate: UIResponder, UIApplicationDelegate {
/** start code copy **/ var pinpoint: AWSPinpoint? /** end code copy **/ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Other didFinishLaunching code... /** start code copy **/ // Create AWSMobileClient to connect with AWS AWSMobileClient.sharedInstance().initialize { (userState, error) in if let error = error { print("Error initializing AWSMobileClient: (error.localizedDescription)") } else if let userState = userState { print("AWSMobileClient initialized. Current UserState: (userState.rawValue)") } } // Initialize Pinpoint let pinpointConfiguration = AWSPinpointConfiguration.defaultPinpointConfiguration(launchOptions: launchOptions) pinpoint = AWSPinpoint(configuration: pinpointConfiguration) /** end code copy **/ return true }
}
amplify init
amplify push
func application(
_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
pinpoint!.notificationManager.interceptDidRegisterForRemoteNotifications( withDeviceToken: deviceToken) }
```
AWS后台会通过device token生成Endpoint ID,功能相同
AWSMobileClient库 部分代码使用Swift编写,如果是使用OC编写的项目,需要进行代码混编的集成
Download Demo
原文:大专栏 iOS集成AWS Push整理