All Products
Search
Document Center

Use SDK

Last Updated: Feb 04, 2021

After adding the SDK, perform the following steps to connect the delivery service to the iOS client:

  1. Detect new version: Call the SDK API method in the code to check whether new versions are available.
  2. Configure whitelist gray release: Configure the functions such as the update reminder and gray release.
  3. 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.

 
  1. typedef NS_ENUM(NSUInteger, AliUpdateType) {
  2. AliUpgradeNewVersion = 201, /*The latest version is currently in use.*/
  3. AliUpgradeOneTime, /*A new version of the client is available, and a single reminder is sent.*/
  4. AliUpgradeForceUpdate, /*A new version of the client is available, and forced upgrade is implemented (obsoleted).*/
  5. AliUpgradeEveryTime, /*A new version of the client is available, and multiple reminders are sent.*/
  6. AliUpgradeRejectLogin, /*Restricted login (obsoleted)*/
  7. AliUpgradeForceUpdateWithLogin /*A new version of the client is available, and forced upgrade is implemented.*/
  8. };
  9. /**
  10. The successful callback of upgrade detection during UI customization
  11. @param upgradeInfos The upgrade information
  12. @{upgradeType:202,
  13. downloadURL:@"itunes://downLoader.xxxcom/xxx",
  14. message:@"New version available, please upgrade",
  15. upgradeShortVersion:@"9.9.0",
  16. upgradeFullVersion:@"9.9.0.0000001"
  17. needClientNetType:@"4G,WIFI",
  18. userId:@"admin"
  19. }
  20. */
  21. typedef void(^AliCheckUpgradeComplete)(NSDictionary *upgradeInfos);
  22. typedef void(^AliCheckUpgradeFailure)(NSException *exception);
  23. @interface MPCheckUpgradeInterface : NSObject
  24. /**
  25. The interval between two single reminders, in days. Default value: 3.
  26. */
  27. @property(nonatomic, assign) NSTimeInterval defaultUpdateInterval;
  28. /**
  29. Modify the UI proxy of the default pop-up window.
  30. */
  31. @property (nonatomic, weak) id<AliUpgradeViewDelegate> viewDelegate;
  32. /**
  33. * Initialize the instance.
  34. */
  35. + (instancetype)sharedService;
  36. /**
  37. Detect updates proactively. If there is an update, the default prompt of mPaaS is displayed in the pop-up.
  38. *
  39. */
  40. - (void)checkNewVersion;
  41. /**
  42. Detect updates proactively. No pop-up is displayed. This method is usually used for UI customization, update detection, and red dot reminder.
  43. @param complete Callback succeeds, and the upgrade information dictionary is returned.
  44. @param failure Callback fails.
  45. */
  46. - (void)checkUpgradeWith:(AliCheckUpgradeComplete)complete
  47. failure:(AliCheckUpgradeFailure)failure;
  48. @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.

       
    1. - (void)checkUpgradeDefault {
    2. [[MPCheckUpgradeInterface sharedService] checkNewVersion];
    3. }
  • Customize the pop-up icon, network prompt toast, or progress bar of the network request group based on the default pop-up of mPaaS.

       
    1. - (void)checkUpgradeWithHeaderImage {
    2. MPCheckUpgradeInterface *upgradeInterface = [MPCheckUpgradeInterface sharedService];
    3. upgradeInterface.viewDelegate = self;
    4. [upgradeInterface checkNewVersion];
    5. }
    6. - (UIImage *)upgradeImageViewHeader{
    7. return APCommonUILoadImage(@"ilustration_ap_expection_alert");
    8. }
    9. - (void)showToastViewWith:(NSString *)message duration:(NSTimeInterval)timeInterval {
    10. [self showAlert:message];
    11. }
    12. - (void)showAlert:(NSString*)message {
    13. AUNoticeDialog* alertView = [[AUNoticeDialog alloc] initWithTitle:@"Information" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    14. [alertView show];
    15. }
  • 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.

       
    1. - (void)checkUpgradeWIthCustomUI {
    2. [[MPCheckUpgradeInterface sharedService] checkUpgradeWith:^(NSDictionary *upgradeInfos) {
    3. [self showAlert:[upgradeInfos JSONString]];
    4. } failure:^(NSException *exception) {
    5. }];
    6. }

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.

 
  1. @implementation MPaaSInterface (Portal)
  2. - (NSString *)userId
  3. {
  4. return @"mPaaS";
  5. }
  6. @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 the Production 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:

           
      1. - (void)checkUpgradeDefault {
      2. [MPCheckUpgradeInterface sharedService].defaultUpdateInterval = 7;
      3. [[MPCheckUpgradeInterface sharedService] checkNewVersion];
      4. }
  • 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.

Code sample