0

案例:我正在为 Ionic 2 应用程序使用 iOS 企业程序。这种分发类型的问题之一是支持更新流。为了解决这个问题,我们在服务器端创建了简单的 JSON 来检查可用的更新。当更新可用时,用户会看到提示更新应用程序或退出的建议。

app.component.ts

    iosUpdateCheck() {
        this.http.get(`${this.config.iosEnterpriseEndpoint}latest.json`).map(res =>
          <{version: string}>res.json()).subscribe((res) => {

          if (res.version !== this.config.appVersionNumber) {
            this.message.alertCtrl.create({
              title: 'Update is available!',
              message: 'Please, update your terminal to proceed',
              buttons: [
                {
                  text: 'Update',
                  handler: () => {
                    console.log(this.TAG + 'iosUpdateCheck: update clicked');
//I tried just href also
                     window.window.open(`<a href=itms-services://?action=download-manifest&url=${this.config.iosEnterpriseEndpoint}manifest.plist />`,'_system');
                  }
                },
                {
                  text: 'Exit',
                  role: 'cancel',
                  handler: () => {
                    console.log(this.TAG + 'iosUpdateCheck: exit clicked');
                    this.platform.exitApp();
                  }
                },
              ]
            }).present();
          }
        });
      }

我还添加了config.xml <allow-intent href="itms-services:*"/>但仍然遇到相同的错误(抱歉,截图,无法在 Safari 中复制错误链接): 在此处输入图像描述 如果我只使用一个链接,它工作正常,但不符合所追求的目标。

4

1 回答 1

0

我认为这个 ionic-native 插件可能会对您有所帮助:Ionic Native Market plugin

安装:

ionic cordova plugin add cordova-plugin-market
npm install --save @ionic-native/market

并且不要将它添加到您的app.module.

用法:

import { Market } from '@ionic-native/market';
constructor(private market: Market) { }

this.market.open('your.package.name');
于 2017-10-27T14:01:47.737 回答