IOS development umeng Push configuration tutorial

Source: Internet
Author: User
Tags key string

IOS development umeng Push configuration tutorial

IOS development umeng Push configuration tutorial
Introduction:
While sorting out computer files, I found a simple tutorial about umeng push that I wrote to my friends. Now I am posting it to my blog post, hoping it will be useful to anyone who needs it.
Development Environment and language:
Xcode7.X,Objective-C
1. Create a project.

1-1 (Xcode7.XConfigurationhttpsNetwork requests)

1-2 integration with umeng pushSDKWhat I integrate here isUMessage_Sdk_1.2.3. Version is1.2.3.
(UmengiOS SDKI will not introduce it here. You can download it from the official website of umeng .)

1-3 code section (mainly inAppDelegate.hAndAppDelegate.mFile)
1-3-1AppDelegate.hFile Content

// AppDelegate. h // TJJUMPushDemo /// Created by WangJiaheng on 16/1/19. // Copyright? Shixiongwei. All rights reserved./* umeng demo Description: 1. A push project was created on umeng's official website. Remember that the bunding id should be consistent with that in the project. 2. Copy umeng key. This is required for registration. 3. Register with umeng for pushing. The methods for registering iOS7 and iOS8 are different. Determine the system version here */# import
  
   
// Youmeng key # define UMKEY_PUSH @ "569dc08567e58eecca00050e" // determine whether the version is iOS8 # define TJJiOS8 [[UIDevice currentDevice]. systemVersion floatValue]> = 8.0 @ interface AppDelegate
   
    
@ Property (strong, nonatomic) UIWindow * window; @ end
   
  

Effect:

1-3-2AppDelegate.mFile Content
(Note: You need to import the header file"#import "UMessage.h"")

# Import "UMessage. h "@ interface AppDelegate () @ end @ implementation AppDelegate-(BOOL) application :( UIApplication *) application metadata :( NSDictionary *) launchOptions {// Override point for customization after application launch. [UMessage startWithAppkey: UMKEY_PUSH launchOptions: launchOptions]; if (TJJiOS8) {// iOS8 and the following registration method // register remoteNotification types (iOS 8.0 and later) UIMu TableUserNotificationAction * action1 = [[UIMutableUserNotificationAction alloc] init]; action1.identifier = @ "action1_identifier"; action1.title = @ "Accept"; action1.activationMode = uiusernotifactivactivationmodeforeground; // when clicked, start the program UIMutableUserNotificationAction * action2 = [[UIMutableUserNotificationAction alloc] init]; // the second button action2.identifier = @ "action2_identifier"; action2.title = @ "Rejec T "; action2.activationMode = uiusernotifactivactivationmodebackground; // if you do not start the program when you click it, process action2.authenticationRequired = YES in the background. // you need to unlock it to process it. activationMode = UIUserNotificationActivationModeForeground; this attribute is ignored; action2.destructive = YES; uimutableusericationicationicationcategory * categorys = [[UIMutableUserNotificationCategory alloc] init]; categorys. identifier = @ "category1"; // the unique identifier of this group of actions [category S setActions: @ [action1, action2] forContext :( actions)]; UIUserNotificationSettings * userSettings = [UIUserNotificationSettings failed: Required | UIUserNotificationTypeSound | categorcategories: [NSSet setWithObject: categorys]; [UMessage registerRemoteNotificationAndUserNotificationSettings: userSettings];} else {// iOS 8.0 Next registration method [UMessage registration: Register | uiremotenotiftypesound | UIRemoteNotificationTypeAlert];} [UMessage setLogEnabled: YES]; return YES ;}# pragma mark-# pragma mark registration-(void) application :( UIApplication *) application didRegisterForRemoteNotificationsWithDeviceToken :( NSData *) deviceToken {[UMessage registerDeviceToken: deviceToken]; NSLog (@ "deviceTo Ken: % @ ", deviceToken); // token value NSLog (@" deviceToken: % @ ", [[[[deviceToken description] stringByReplacingOccurrencesOfString: @" <"withString: @ ""] stringByReplacingOccurrencesOfString: @ ">" withString: @ ""] stringByReplacingOccurrencesOfString: @ "" withString: @ ""]); // token value, copy this line when adding a test device. Note that it cannot contain spaces .} # Pragma mark-# pragma mark receives the PUSH message-(void) application :( UIApplication *) application didReceiveRemoteNotification :( NSDictionary *) userInfo {[UMessage didReceiveRemoteNotification: userInfo];}

As follows:

1-4 certificate configuration,bunding IDConfiguration. here you need to create a push certificate. The following describes how to create and configure a certificate.
Herebunding IDIs"com.umpushdemo.TJJUMPushDemo".

2. Create an application on the umeng official website and activate message push.
2-1 log on to umeng official website and create an application. After creating an application, the results are as follows:AppKeyIs unique. This is also the umeng defined by the macro in the code.Key)

2-2 add message push. (The procedure is as follows :)

Next step:
Vc/IzPi5/aGjoaOho6GjoaOho6GjoaPM + Neqtb0mbGRxdW87PHN0cm9uZz69 + signature + DQo8cD4yLTQgyc + signature "6" src = "http://www.bkjia.com/uploads/allimg/160416/0433422223-6.png" title = "\"/>

Next step:

Next step:

3. Create a certificate by pushing the certificate (the process for publishing a certificate is the same as that for developing a certificate here)
3-1 createAPP ID(APP IDIt must be unique and cannot contain wildcards)

Next step:

Next step:

Next step:

Next step:

3-2 create certificate development push Certificate
3-2-1 Add the development push Certificate

Next step:

3-2-2 related configuration Selection

Next step:

Next step:

3-2-3 open the key string tool on our computer and create an organization to request a certificate

Next step:

After creating the CA request certificate, save it to the local disk, open the apple developer website, and continue the configuration. Upload the CA request certificate.

After the upload is successful, download the certificate to your local device and install it on both sides. (P12 file needs to be exported)

After configuring the development push certificate, you can click the APP id corresponding to the app IDs to view the information as follows:

3-3 export the P12 file (prerequisite: Install the downloaded certificate file .)
3-3-1 open the key string

Next step:

Next step:

3-4 Create a certificate description file and install it. This file is required in Xcode certificate configuration. (3-3 export the P12 file. You can continue to create the configuration of umeng push Application 2-4. Return to step 2 to Step 4 .)

Next step:

Next step:

Next step:

Next step:

Next step:

Next step:

After all the certificates are completed, there should be four. As follows.

4. Xcode project configuration
XcodeRun the application and print outTokenTo add a device, you must specifyTokenValue, corresponding to each iOS deviceTokenValues are unique.
This is used for umeng testing. If we need to push the server back-endTokenThe value must be passed to our own backend server. You don't need to know how to transfer the value. It should be the background service interface that Concatenates the upload parameters. Here, I only printed the project.

4-1 in Xcode, configure the application.
1) bunding id.

2) Select a certificate

3) After the application runs:

4) print the Token value on the Xcode console:

5. Push the test and log on to umeng. Select the created application. Click push message.

5-1. Add a test device. Token value required

Next step:

Next step:

IOS device effect:

 

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.