ionic-frameworklocalnotification

Ionic Local Notifications


I have a problem that I can't solve. I created an ecommerce with woocommerce. I use onesignla to send update notifications etc. But I want each user to have their own notification when the order changes status eg: From Received to Completed ... I have tried with localnotification but unsuccessfully is anyone able to help me?

my-orders-page.ts

orderstatus: any;

orderChangeStatus(){
    if (this.orderstatus == 'processing') {
      this.LocalNotifications.schedule({
        title: 'My first notification',
        text: 'flight is landed',
        foreground: true

      });
    }
    if (this.orderstatus == 'completed') {
      this.LocalNotifications.schedule({
        title: 'My first completed',
        text: 'flight is landed',
        foreground: true

      });
    }

  }

html

    </ion-row>
    <ion-row [class.pending]="order.status=='pending' || order.status=='refunded'"
      [class.cancel]="order.status=='cancelled' || order.status=='failed'"
      [class.inprocess]="order.status=='processing'" [class.complete]="order.status=='completed'">
      <ion-col size="6">
        {{'Status'|translate}}
      </ion-col>
      <ion-col class="ion-text-right" size="6">
        <strong>{{order.status|translate}}</strong>
      </ion-col>
    </ion-row>

Solution

  • Ionic Local Notifications is for notifications that are triggered from the app itself, without push notifications server (for example, a calendar reminder). They're not suitable for push notifications unless you have set your own push notification framework with background workers.

    You should instead use Ionic OneSignal plugin. Find out the documentation here: https://ionicframework.com/docs/native/onesignal

    I cannot help you more at this stage, you should try to use this plugin and if you have further problems, please ask another question.