1. Configure the development certificate (must have the developer account, individual, Enterprise's can)Development environment Testing
Before testing the Jpush IOS development environment, make sure that you have 3 unified:
- APP is a development environment package (Development certificate development)
- The development certificate was uploaded and verified by
- Applications on the Portal are set to the development environment
Publish an environment test
Before testing the Jpush IOS production environment, make sure that you have 3 unified:
- App is Ad-hoc package or app Store version (publish certificate Production)
- Upload the publishing certificate and verify that the
- The app on the Portal is set to the production environment
IOS Certificate Setup Guide to create an application ID
- Log in to iOS Dev Center to opt into iOS Provisioning Portal.
- In IOS Provisioning portal, click App IDs to enter the app ID list.
- Create an APP ID that can skip this step if the ID already exists
- Turn on the Push Notification feature for your App. If you have already created an App ID, you can also turn on the Push Notification feature by setting it up.
According to the actual situation to improve the APP ID information and submit, note here need to specify the specific Bundle ID do not use wildcard characters.
Configure and download certificates
- If you have not created a Push certificate before or want to recreate a new one, please create it under the list of certificates.
- New certificate requires attention to select a certificate type (development certificate for development and debugging use, production certificate for APP Store release)
- Click Continue to select the app ID for the certificate, and then continue with "about Creating a Certificate Signing Request (CSR)."
- Create the Certificate Signing request by creating an open keychainaccess according to its instructions.
- After completing "User Email Address" and "Common Name", select Saved to disk for saving.
- Continue back to Apple Developer website Click Continue to upload the. certsigningrequest file you just generated APNs Push Certificate.
- Download and double-click the open certificate, which launches the Keychain Access tool when the certificate is opened.
- In keychain access, your certificate appears in my certificates, and you can select my certificates and login
Export the. P12 certificate file
注意要选“login”和“My Certificates” 导出证书时要选中证书文件,不要展开private key。
- Save the file in the personal information Exchange (. p12) format.
- Save the file in the personal information Exchange (. p12) format.
Upload Certificate
On the Jpush management Portal, for an application, upload the steps above to get the. P12 certificate file. This is the necessary step for the IOS SDK to receive jpush push messages.
Creation of Provisioning Profile
- The premise of creating a provisioning profile is to create an app ID for the bundle ID used by the app to be published on the Apple Developer website, and to create a APNS certificate for that app ID, such as:
To create an app ID, an APN certificate, and an export of the P12 certificate, see the following: IOS Certificate Setup Guide
On the Provisioning profile page of the Apple Developer account, click the button to create the provisioning profile
- Select the environment for this provisioning profile and click [Continue]:
- Select the app ID you want to create provisioning profile and click [Continue]:
- Select the developer certificate that belongs to, (there are many developer certificates created here, it is recommended to create only one, easy to manage) for convenience, select [All] and click [Continue] to proceed to the next step:
- Select the device that will be installed for the provisioning profile (General select [All]), and click [Continue]:
- Fill in the profile Name for the provisioning profile and click [Generate] to complete the creation.
- After completing the profile name, click [Generate] to complete the creation, then click [DownLoad] To download the provisioning profile.
- Double-click the downloaded provisioning profile and add it to Xcode.
2. Xcode's certificate Configuration tutorial
Follow the iOS SDK Integration Guide to integrate the Jpush SDK and upload a push-to-use P12 certificate before compiling to run the certificate, the steps are as follows:
- Open Xxx-info.plist Bundle identifier to fill in the bundle ID uploaded to the jpush console:
- Click on Project, select target targets and go to build Setting interface, search "Code signing", follow the configuration
Client Settings Open Remote notifications
To change the application's capabilities in Xcode to open remote notifications, refer to:
3.SDK Integration Steps
Integrated Compressed Package Content
Package name is jpush-ios-sdk-{version number}
- Lib folder: Contains header file JPUSHService.h, static library file jpush-ios-x.x.x.a, supported iOS version 5.0 and later. (Note: Emulator does not support APNs)
- PDF file: Integration Guide
- Demo folder: Example
Development environment
- Using XCode 6 and later, you can use the new push Sdk,xcode 5 environment to run an older version of the SDK (1.7.4)
1. Create an app on Jpush portal
- Create an app on Jpush's management portal and upload the APNs certificate. If you are not familiar with the APNs certificate, please refer to: IOS Certificate Setup Guide
- The AppKey is automatically generated after a successful creation to identify the app.
2. Import API Development package to application project
- Unzip the SDK package, select "Add Files to ' Your project name ' ..." in Xcode and add the extracted Lib subfolders (including JPUSHService.h, JPUSH-IOS-X.X.X.A) to your project directory.
3, the necessary framework
- Cfnetwork.framework
- Corefoundation.framework
- Coretelephony.framework
- Systemconfiguration.framework
- Coregraphics.framework
- Foundation.framework
- Uikit.framework
- Security.framework
- Xcode7 need is libz.tbd;xcode7 the following version is Libz.dylib
4. Build Settings
If your project needs to support iOS systems less than 7.0, go to build Settings to turn off the bitcode option, otherwise it will not compile properly.
- Set the User Header search Paths and the library search Paths under Search Paths, such as the SDK folder (the default is Lib) and the project file in the same level directory, are set to "$ (srcroot)/{the file where the static library resides Folder name} ".
5. Create and configure the Pushconfig.plist file
Beginning with the 2.1.0 version, the Setupwithoption initialization method with parameters is added, which can be passed into Appkey and other information through parameters such as this method. 1.8.8 and previous versions of the Jpush SDK can only be configured with Pushconfig.plist Appkey and other information.
Create a new property list file in your project and name it pushconfig.plist, with the following fields in the file:
- CHANNEL
- Specifies the download channel for the application package, which is defined by you, such as the app Store, for ease of channel statistics.
- App_key
- Fill out the Appkey values that are automatically generated when the app is created on the management portal. Make sure that the AppKey in the in-app configuration is consistent with the AppKey generated after the 1th step is created on the Portal.
- Aps_for_production
- The 1.3.1 version is new to identify the APNS certificate environment used by the current app.
- 0 (the default) indicates that a development certificate is used and 1 means that the application is published with a production certificate.
- Note: The value of this field is consistent with the certificate environment configured for the code signing of build settings.
- In 1.2.2 or previous version of the configuration file, there is test_mode this key, the new version of the SDK is no longer used, you can delete it.
Pushconfig.plist File Example diagram:
6. Add code
Starting with the 2.1.0 version, the API class is named Jpushservice and no longer uses the original apservice.
Allow XCode7 to support HTTP transfer methods
If you are using XCODE7, you need to manually add the following keys and values to the plist of the app project to support HTTP transport:
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
Integrating the required APIs
APIs are mainly concentrated in the Jpushservice interface class.
4. Project code:
AppDelegate.h inside the code:
#import <UIKit/UIKit.h>
Staticnsstring *appkey = @ "4fd48a0712a3fde75eb1c7423";//The official will provide it to you after the application is successful.
Staticnsstring *channel = @ "Publish channel";
Staticbool isproduction = FALSE;
@interface Appdelegate:uiresponder <UIApplicationDelegate>
@property (strong,nonatomic) UIWindow *window;
@end
#import code in "APPDELEGATE.M"
#import "AppDelegate.h"
#import "JPUSHService.h"
@interface Appdelegate ()
@end
@implementation Appdelegate
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {
Override point for customization after application launch.
Self.window.backgroundColor = [Uicolorwhitecolor];
[Self.windowmakekeyandvisible];
if ([[Uidevicecurrentdevice].systemversionfloatvalue] >= 8.0) {
You can add a custom categories
[Jpushserviceregisterforremotenotificationtypes: (Uiusernotificationtypebadge |
Uiusernotificationtypesound |
Uiusernotificationtypealert)
Categories:nil];
} else {
The categories must be nil.
[Jpushserviceregisterforremotenotificationtypes: (Uiremotenotificationtypebadge |
Uiremotenotificationtypesound |
Uiremotenotificationtypealert)
Categories:nil];
}
[Jpushservicesetupwithoption:launchoptions Appkey:appkey
Channel:channelapsForProduction:NO];
Returnyes;
}
-(void) Application: (UIApplication *) application Didregisterforremotenotificationswithdevicetoken: (NSData *) Devicetoken {
Required
[Jpushserviceregisterdevicetoken:devicetoken];
}
-(void) Application: (UIApplication *) application didreceiveremotenotification: (Nsdictionary *) UserInfo {
Required,for systems with less than or equal to IOS6
[Jpushservicehandleremotenotification:userinfo];
}
-(void) Application: (UIApplication *) application didreceiveremotenotification: (nsdictionary *) userInfo Fetchcompletionhandler: (void (^) (uibackgroundfetchresult)) Completionhandler {
IOS 7 Support Required
[Jpushservicehandleremotenotification:userinfo];
Completionhandler (Uibackgroundfetchresultnewdata);
}
-(void) Application: (UIApplication *) application Didfailtoregisterforremotenotificationswitherror: (NSError *) error {
Optional
NSLog (@ "did Fail to Register for Remote notifications with error:%@", error);
}
-(void) Applicationwillresignactive: (uiapplication *) Application {
Sent when the application are about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as a incoming phone call or SMS message) or when the US Er quits the application and it begins the transition to the background state.
Use the This method to the pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
-(void) Applicationdidenterbackground: (uiapplication *) Application {
Use the This method to release the shared resources, save user data, invalidate timers, and store enough application state info Rmation to the restore your application to the it is terminated later.
If your application supports background execution, this method is called instead of Applicationwillterminate:when the User quits.
}
-(void) Applicationwillenterforeground: (uiapplication *) Application {
Called as part of the transition from the background to the inactive state; Here's can undo many of the changes made on entering the background.
}
-(void) Applicationdidbecomeactive: (uiapplication *) Application {
Restart any tasks this were paused (or not yet started) while the application is inactive. If the application is previously in the background, optionally refresh the user interface.
}
-(void) Applicationwillterminate: (uiapplication *) Application {
Called when the application are about to terminate. Save data if appropriate. See also Applicationdidenterbackground:.
}
@end
4. Real-Machine testing: Login to the Aurora push: Click on the console:
Select the app, which is the project you created the test for: my project is AA. Testpush
Select later to click here to enter:
Click on the push above:
Click Send notification on the left, or you can select a custom message (here I choose to send a notification):
I'll write something here. Test with my phone:
Click Send Now:
The display on the phone:
iOS Aurora push