After adding the SDK, perform the following steps to connect the delivery service to the iOS client:
Detect new version: Call the SDK API method in the code to check whether new versions are available.
Configure whitelist gray release: Configure the functions such as the update reminder and gray release.
Online release: Generate an .ipa file in the mPaaS console, and release a new version.
Procedure
Detect new version
The upgrade detection SDK provides an API file to check available App upgrades. The method header file is in the AliUpgradeCheckService.framework > Headers > MPCheckUpgradeInterface.h
file.
typedef NS_ENUM(NSUInteger, AliUpdateType) {
AliUpgradeNewVersion = 201, /*The latest version is currently in use.*/
AliUpgradeOneTime, /*A new version of the client is available, and a single reminder is sent.*/
AliUpgradeForceUpdate, /*A new version of the client is available, and forced upgrade is implemented (obsoleted).*/
AliUpgradeEveryTime, /*A new version of the client is available, and multiple reminders are sent.*/
AliUpgradeRejectLogin, /*Restricted login (obsoleted)*/
AliUpgradeForceUpdateWithLogin /*A new version of the client is available, and forced upgrade is implemented.*/
};
/**
The successful callback of upgrade detection during UI customization
@param upgradeInfos The upgrade information
@{upgradeType:202,
downloadURL:@"itunes://downLoader.xxxcom/xxx",
message:@"New version available, please upgrade",
upgradeShortVersion:@"9.9.0",
upgradeFullVersion:@"9.9.0.0000001"
needClientNetType:@"4G,WIFI",
userId:@"admin"
}
*/
typedef void(^AliCheckUpgradeComplete)(NSDictionary *upgradeInfos);
typedef void(^AliCheckUpgradeFailure)(NSException *exception);
@interface MPCheckUpgradeInterface : NSObject
/**
The interval between two single reminders, in days. Default value: 3.
*/
@property(nonatomic, assign) NSTimeInterval defaultUpdateInterval;
/**
Modify the UI proxy of the default pop-up window.
*/
@property (nonatomic, weak) id<AliUpgradeViewDelegate> viewDelegate;
/**
* Initialize the instance.
*/
+ (instancetype)sharedService;
/**
Detect updates proactively. If there is an update, the default prompt of mPaaS is displayed in the pop-up.
*
*/
- (void)checkNewVersion;
/**
Detect updates proactively. No pop-up is displayed. This method is usually used for UI customization, update detection, and red dot reminder.
@param complete Callback succeeds, and the upgrade information dictionary is returned.
@param failure Callback fails.
*/
- (void)checkUpgradeWith:(AliCheckUpgradeComplete)complete
failure:(AliCheckUpgradeFailure)failure;
@end
Developers can call the corresponding API to detect updates after the app is started. We recommend that you call the API after the homepage is displayed so that the startup time of the app is not affected. The following three calling methods are provided for different UI requirements for the display of upgrade prompt information:
Use the default pop-up of mPaaS to display the upgrade prompt information.
- (void)checkUpgradeDefault { [[MPCheckUpgradeInterface sharedService] checkNewVersion]; }
Customize the pop-up icon, network prompt toast, or progress bar of the network request group based on the default pop-up of mPaaS.
- (void)checkUpgradeWithHeaderImage { MPCheckUpgradeInterface *upgradeInterface = [MPCheckUpgradeInterface sharedService]; upgradeInterface.viewDelegate = self; [upgradeInterface checkNewVersion]; } - (UIImage *)upgradeImageViewHeader{ return APCommonUILoadImage(@"ilustration_ap_expection_alert"); } - (void)showToastViewWith:(NSString *)message duration:(NSTimeInterval)timeInterval { [self showAlert:message]; } - (void)showAlert:(NSString*)message { AUNoticeDialog* alertView = [[AUNoticeDialog alloc] initWithTitle:@"Information" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alertView show]; }
Call the following API to obtain the upgrade information and customize the UI if the pop-up styles provided by mPaaS do not meet your requirements.
- (void)checkUpgradeWIthCustomUI { [[MPCheckUpgradeInterface sharedService] checkUpgradeWith:^(NSDictionary *upgradeInfos) { [self showAlert:[upgradeInfos JSONString]]; } failure:^(NSException *exception) { }]; }
Configure whitelist gray release
To use the whitelist gray release function in release management, ensure that you have obtained the unique identity of the client on the server. Configure the unique user identity in category of MPaaSInterface on the client, and return a unique identity of the app in the userId
method, for example, the user name, mobile phone number, email address, etc.
@implementation MPaaSInterface (Portal)
- (NSString *)userId
{
return @"mPaaS";
}
@end
For details on how to configure the whitelist in the mPaaS console, see Delivery Service > Manage whitelist.
Online release
Generate an .ipa file
Use Xcode to generate an .ipa installation package.
Alternatively, generate an .ipa installation package with the packaging function provided by the mPaaS plug-in. The generated package will be stored in the
product
directory under your current project.Bundle Identifier: It must be consistent with
bundle Id
in the cloud configuration file.Bundle Version: It must be consistent with
info.plist
in theProduction Version
file for the project.Provisioning Profile: Signature configuration file. It must be consistent with
bundle Id
, or package generation will fail.Debug: Specifies whether to generate the debug installation package.
App Store: Specifies whether to generate a package for release in the App Store.
Release a new version
Use the release management function of the release platform to release a new version. For details about the release process, see Release management.
Upgrade mode:
When creating a release task in the mPaaS console, choose one of the following upgrade modes:
Single reminder: After a new version is released in the mPaaS console, the client calls the version upgrade API once and displays the pop-up only once in the silence period to avoid disturbing users.
This upgrade mode is suitable for instructing users to perform an upgrade upon the release of a new version.
By default, the silence period is 3 days, during which a user is notified only once. To change the length of the silence period, set the following properties before calling the upgrade detection API:
- (void)checkUpgradeDefault { [MPCheckUpgradeInterface sharedService].defaultUpdateInterval = 7; [[MPCheckUpgradeInterface sharedService] checkNewVersion]; }
Multiple reminders: After a new version is released in the mPaaS console, the client displays a pop-up reminder each time it calls the version upgrade API. This upgrade mode is suitable for instructing users to upgrade the app to the new version as soon as possible after the new version has been released for a period of time.
Mandatory reminder: After a new version is released in the mPaaS console, the client displays a pop-up reminder without the Cancel button each time it calls the version upgrade API. Users can no longer use the app without an upgrade. This upgrade mode is suitable for forcing users to upgrade the app to the new version and unpublishing the earlier app version.