Alibaba Cloud Mobile Push is a mobile cloud service that uses big data technology. You can add mobile push features to your app to send efficient, precise, and real-time push notifications. This service reduces development costs and increases user activity and retention rates.
| Dependent SDK | Overview |
| API channel | Provides API channel features and basic environment configuration. |
Configure the service
The features in this SDK depend on the Alibaba Cloud Mobile Push service. You must configure the service in the console before you use these features. For more information, see Mobile Application Push Developer Guide.
Initialization
To initialize the SDK, see SDK Initialization.
Usage
- Set up APNs with Apple.The APNs token is requested during SDK initialization. No extra steps are required.
- Listen for push notifications.
/* * Callback for when a notification is opened while the app is running. */ - (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo { NSLog(@"Receive one notification."); // Get the APNS notification content. NSDictionary *aps = [userInfo valueForKey:@"aps"]; // Content NSString *content = [aps valueForKey:@"alert"]; // Badge number NSInteger badge = [[aps valueForKey:@"badge"] integerValue]; // Play sound NSString *sound = [aps valueForKey:@"sound"]; NSLog(@"content = [%@], badge = [%ld], sound = [%@]", content, (long)badge, sound); // Clear the iOS badge. application.applicationIconBadgeNumber = 0; // Report that the notification was opened. [[IMSIotSmart sharedInstance] application:application didReceiveRemoteNotification:userInfo]; }The SDK initialization code handles the logic for the following actions. No additional operations are required.
- Associate Mobile Push with an account
When a user logs on, the app automatically associates Mobile Push with their account. This action uses the
/uc/bindPushChannelAPI service. - Disassociate Mobile Push from an account
When a user logs off, the app automatically disassociates Mobile Push from their account. This action uses the
/uc/unbindPushChannelAPI service.
- Associate Mobile Push with an account
Alerting feature
The alerting feature depends on user-device binding. This binding is included in the SDK initialization. Therefore, you only need to focus on the business logic for the alerting feature.