Development practices for the Alibaba Cloud International Website

更新时间:
复制 MD 格式

Developing products for the Alibaba Cloud China Website (www.aliyun.com) is different from developing them for the Alibaba Cloud International Website (www.alibabacloud.com). This topic describes the changes required to develop products for the Alibaba Cloud International Website.

Device-side development

For more information about device-side development on the Alibaba Cloud International Website, see Device development for the Alibaba Cloud International Website.

Configure the console

Follow these steps to create products and proprietary apps on both the Alibaba Cloud China Website and the Alibaba Cloud International Website.

  1. Set Site to Alibaba Cloud International Website.

  2. Create a project. For more information, see Create a project.

  3. Create a product in the project and define its features. For more information, see Create a product and define its features.

  4. Set the app feature parameters. For more information, see Overview. In Multi-language Management, configure the product name and features in English or another language.

    多语言管理

  5. Create a proprietary app in the project. For more information, see Create a proprietary app.

    Note

    The package name, signature (for Android), and bundleID (for iOS) for the app must be the same on both the Alibaba Cloud International Website and the Alibaba Cloud China Website.

  6. Set Site to Alibaba Cloud China Website, and repeat the preceding steps to create the product and proprietary app on the Alibaba Cloud China Website.

Client-side development

  1. Integrate the security images.

    Follow the instructions in Integrate security images to obtain the security images from the Alibaba Cloud China Website and the Alibaba Cloud International Website. Then, integrate both images into your app project.

    Alibaba Cloud China Website

    Alibaba Cloud International Website

    yw_1222_china_production.jpg

    yw_1222_oversea_production.jpg

    • Android放置安全图片

    • iOS

  2. Download and integrate the SDK. For more information, see Download and integrate the SDK.

  3. Initialize the SDK. For more information, see SDK initialization (Android) and SDK initialization (iOS).

    When you initialize the SDK, set the access type. For the Alibaba Cloud International Website, you must set it to REGION_ALL.

  4. Set the country information.

    If your app will run in regions outside the Chinese mainland and needs to switch between the Chinese mainland and other regions, users must set their country or region before they register an account.

    Note

    The country selected during account registration determines whether the app connects to the Chinese mainland or to other regions (including Hong Kong, Macao, and Taiwan). The app must be restarted when it switches between the Chinese mainland and other regions.

    • Obtain country/region information

      For iOS:
      [[IMSIotSmart sharedInstance] getCountryList:^(NSError * _Nullable error, NSArray<IMSIotCountry *> * _Nullable countryList) {
          // The returned countryList is raw data.
         
        }];
      For Android:
      public static void getCountryList(final ICountryListGetCallBack callback)
          IoTSmartImpl.getInstance().getCountryList(callback);
        }
    • Set the country/region

      For iOS:
      [[IMSIotSmart sharedInstance] setCountry:_selectCountry callback:^(BOOL needRestartApp) {
          if (needRestartApp) {
            ////You must exit the application. Otherwise, it will not work correctly.
          }
        }];
      For Android:
      IoTSmart.setCountry(mSelectedCountry, needRestartApp -> {
                if (needRestartApp) {
                    ////You must exit the application. Otherwise, it will not work correctly.
                 }
      });
    • Obtain the configured country/region

      For iOS:
      IMSIotCountry *country = [[IMSIotSmart sharedInstance] getCountry];
      For Android:
      GlobalConfig.getInstance().getCountry()
  5. Set the international language.

    IoT Platform currently supports 11 languages, including Chinese (zh-CN), English (en-US), French (fr-FR), German (de-DE), Japanese (ja-JP), Korean (ko-KR), Spanish (es-ES), Russian (ru-RU), Italian (it-IT), Hindi (hi-IN), and Portuguese (pt-PT).

    Use the following settings to change the language of the SDK.

    For Android:
    IoTSmart.setLanguage(languageName);
    // View the current language setting of the SDK.
     public static String getLanguage() {
            return IoTSmartImpl.getInstance().getLanguage();
    }
    For iOS:
    NSString *language = @"zh-CN";
    [[IMSIotSmart sharedInstance] setLanguage:language];
    
    // View the current language setting of the SDK.
    NSString *language = [[IMSIotSmart sharedInstance] getLanguage];

    For iOS, you may also need to set the language for the OA UI.

    设置语言

    // Use the default translation resource file.
        [[IMSiLopOALanguageManage shareInstance]
        setOpenAccountModuleLanguageWithLanguagePrefix:@"ko"];
    
    
    // Use your own resource file.
    // Copy the .lproj file from IMSOpenAccountCustomResource.bundle in IMSOpenAccountCustom, and create a multilingual translation file with the same keys.
        [[IMSiLopOALanguageManage shareInstance] 
        setOpenAccountModuleLanguageWithLanguagePrefix:@"ko" bundleName:@"xxxx"];

App debugging instructions

After you finish developing your product for the Alibaba Cloud International Website, note the following when you debug the development version of the app in the Chinese mainland.

  • For the app's region, select any region other than "Chinese mainland".

  • When you register or log on with a mobile phone number, select a country code. For example, the country code for the Chinese mainland is "+86".

Cloud-side development

When you call a cloud API to send a request to cloud services on the Alibaba Cloud International Website, you must change the Host in the request message. By default, the Host is set for the Alibaba Cloud China Website. If you do not change the Host, the API call fails. For more information about calling cloud APIs, see Overview.

  • For Java:

    ApiResponse response = syncClient.postBody("api-iot.ap-southeast-1.aliyuncs.com",
    "/cloud/token", request, true);
  • For PHP:

    function example() { 
    $path = "/cloud/token"; 
    $host = "https://api-iot.ap-southeast-1.aliyuncs.com"; 
    $appKey = "your_app_key"; 
    $appSecret = "your_app_secret"
    ...
    }