IOS push (Baidu push)

Source: Internet
Author: User
Tags key string

IOS push (Baidu push)

I am using push recently, so I 'd like to share with you my problems and solutions !!

1. First generate the CertificateSigningRequest file.

Click the access key string --> request a certificate from the Certificate Authority --> enter the user email address --> common name --> click Save --> continue --> finally click Save.

On the desktop, you can see that the CertificateSigningRequest. certSigningRequest file is the CSR file. When we generate the CSR file, a pair of keys will be generated during key string access. The name is the common name we just filled in.

 

 

2. Open the Developer Center and first create Identifiers --> Create Certificates --> Create Provisoning Profiles

Note: 1. When creating Identifiers, checkPush Notifications,

2. Ensure that the IDs in Identifiers, the names in Certificates, the APP IDs in Provisoning Profiles, and the Bundle identifier in the application are consistent.

 

3. Click the access key string --> my certificate --> Find the generated. p12 file --> Click Export to desktop.

4. Open the Middle-end --> openssl pkcs12-in push. p12-out push. pem-nodes, and convert the. p12 file to the. pem file.

 

5. Add the SDK? The steps in the project are as follows:

Add libBPush. a and BPush. h? ? Your? When adding a project, check the current Target

 

6. Create and configure the BPushConfig. plist file, create a new Property List file in the project, name it BPushConfig. plist, and add the following key values:

 

{    “PRODUCTION_MODE” = NO    “API_KEY” = “uZbmgZKhfumvGYGowcjSPFc1”     “DEBUG” = NO}

 

PRODUCTION_MODE:

Required. Application publishing mode. When developing a certificate signature, set the value to "NO"; when publishing the Certificate Signature, set the value to "YES ". Modify the correct value when debugging and releasing an application to avoid the arrival of push notifications.

API_KEY:

Required. The api key automatically assigned by the Baidu Developer Center for each app can be viewed in the basic information of the Developer Center app.

 

6. the SDK requires the following

Library: Foundation. framework, CoreTelephony. framework, libz. dylib, and SystemConfiguration. framework? Add in Project

 

7. In AppDelegate, where is the application: didfinishlaunchingwitexceptions: called? Use APIs to initialize Push:

The version of the device must be determined because the push is changed in ios8.

 

[BPush setupChannel: launchOptions]; [BPush setDelegate: self]; // The parameter object must implement onMethod: response: method,
# If SUPPORT_IOS8 // 8.0 and later, use this method to register the push notification if ([[UIDevice currentDevice] systemVersion] floatValue]> = 8.0) {UIUserNotificationType myTypes = UIRemoteNotificationTypeBadge | custom | uiremotenotificationicationtype; UIUserNotificationSettings * settings = [UIUserNotificationSettings attributes: myTypes categories: nil]; [[UIApplication sharedApplication] registerUserNotificationSettings: settings];} else # endif {UIRemoteNotificationType myTypes = optional | required; [[UIApplication sharedApplication] registerForRemoteNotificationTypes: myTypes];}

8. Call the API in application: didRegisterForRemoteNotificationsWithDeviceToken: and register the device token:

 

 

[BPush registerDeviceToken: deviceToken]; // required: [BPush bindChannel]; // required. It can be called at other times. The app can receive Push messages only when the method returns (via onMethod: response: callback) binding is successful. You can bind an app at least once (if the access token is changed, bind it again ).

9. To implement the BPushDelegate protocol, you must implement the onMethod: response ::

 

 

 if ([BPushRequestMethod_Bind isEqualToString:method])     {        NSDictionary* res = [[NSDictionary alloc] initWithDictionary:data];        NSString *appid = [res valueForKey:BPushRequestAppIdKey];        NSString *userid = [res valueForKey:BPushRequestUserIdKey];        NSString *channelid = [res valueForKey:BPushRequestChannelIdKey];        int returnCode = [[res valueForKey:BPushRequestErrorCodeKey] intValue];        NSString *requestid = [res valueForKey:BPushRequestRequestIdKey];    }

 

10. Call the API in application: didReceiveRemoteNotification: to process the received Push message:

Obtain the data returned after the push

 

[BPush handleNotification: userInfo]; // optional

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.