简体   繁体   English

使用ionic 3和cordova 8提醒另一个应用程序

[英]Alert to another app with ionic 3 and cordova 8

I want to send and alert from an app to another one. 我想从应用程序发送并提醒另一个应用程序。 I'm developing both applications and they are talking, but I'm confusing in this alert question. 我正在开发这两个应用程序而且他们正在谈论,但我在这个警报问题中感到困惑。 Here is my code: 这是我的代码:

<ion-item style="align-items: center;">
  <button color="green" ion-button (click)="presentAlert()">
    <ion-icon name="alert"></ion-icon>&nbsp; {{'o que quer alertar?' | translate}}
  </button>
</ion-item>

presentAlert() {
  let alert = this.alertCtrl.create({
    title: '!!* Atenção *!!',
    subTitle: 'Uma mensagem de alerta!',
    buttons: ['Já vou ver...']
  });
  alert.present();
}

It works normally at the same app. 它在同一个应用程序中正常工作。 How can I send this alert to another app? 如何将此警报发送到其他应用程序?

EDIT: pick-up.html (sender) 编辑:pick-up.html(发件人)

<ion-item (click)="getDirection(trip.destination.location.lat,trip.destination.location.lng)">
          <h2 class="font-lbr">{{'Destino' | translate}}</h2>
          <p class="font-lbr-p">{{ trip.destination.vicinity }}</p>
          <button color="green" item-right dark ion-button (click)="getDirection(trip.destination.location.lat,trip.destination.location.lng)">
            <ion-icon name="navigate"></ion-icon>&nbsp; {{'Navegar' | translate}}
          </button>
        </ion-item>

        <allow-intent href="receiver://*/*" />

      </ion-list>

Now, the "receiver", tracking.ts... 现在,“接收器”,tracking.ts ......

playAudio(){
        if(PLAY_AUDIO_ON_REQUEST == true){
          let audio = new Audio(AUDIO_PATH);
          audio.play();
        }
      }

      this.deeplinks.route({
        '/alert': 'Alert',
        '/navigate': 'Navigate',
    }).subscribe(match => {
        if (match.$route === 'Alert') {
            let alertData = {
                title: match.$args['title'],
                subtitle: match.$args['subtitle'],
                button1text: match.$args['button1text']
                button2text: match.$args['button2text']
            }
            presentAlert(alertData);
         }
    }, nomatch => {
        //handle no match
    });

    }

That's the right way? 那是正确的方法吗?

EDIT2: I don't have deeplinks plugin here... EDIT2:我这里没有deeplinks插件......

screenshot 截图

You can use the the deeplinks plugin. 您可以使用deeplinks插件。 Lets assume you have sender and receiver app. 让我们假设您有发送者和接收者应用程序。 Receiver app needs to have a unique URL scheme like this receiver://alert?title=title&subtitle=subtitle&button1text=buttontext&button2text=button2text . Receiver app需要有一个像这个receiver://alert?title=title&subtitle=subtitle&button1text=buttontext&button2text=button2text这样的唯一URL方案receiver://alert?title=title&subtitle=subtitle&button1text=buttontext&button2text=button2text

Use the code along the lines 沿着这条线使用代码

   this.deeplinks.route({
       '/alert': 'Alert',
       '/navigate': 'Navigate',
   }).subscribe(match => {
       if (match.$route === 'Alert') {
           let alertData = {
               title: match.$args['title'],
               subtitle: match.$args['subtitle'],
               button1text: match.$args['button1text']
               button2text: match.$args['button2text']
           }
           presentAlert(alertData);
        }
   }, nomatch => {
       //handle no match
   });

You might require allow-intent in sender app 您可能需要在发件人应用中使用allow-intent

<allow-intent href="receiver://*/*" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM