Ionic 3 onesignal two push arrives

hello
when i send a push form onesignal to android device the notifaction arrive twice one with bell icon when i click it disapper without any action another with app icon when i press the app open
i use crosswalk in my project

please help me to solve this problem

Have you checked your OneSignal account to see if your device is registered twice?
eg: Once for an Android version and once for a browser.

only register once not twice

Can you provide your code showing how you have this set up?

this is my code

import { Component, ViewChild } from '@angular/core';
import { DetailPage } from '../pages/detail/detail';
import {AlertController} from "ionic-angular";
import { Platform, Nav } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { HomePage } from '../pages/home/home';
import { AboutPage } from '../pages/about/about';
import { ContactPage } from '../pages/contact/contact';
import { GalleryPage } from '../pages/gallery/gallery';
import { NotifPage } from '../pages/notifaction/notifaction';
import { OffersPage } from '../pages/offers/offers';
import { ServicePage } from '../pages/serv/serv';

@Component({
  templateUrl: 'app.html'
})

export class MyApp {
  @ViewChild(Nav) nav: Nav;
  rootPage = HomePage;
  pages: Array<{title: string, component: any}>;
  constructor(public platform: Platform,public statusBar: StatusBar,public splashScreen: SplashScreen,  public alertCtrl: AlertController) {
    
    platform.ready().then(() => {
 if (splashScreen) {
        setTimeout(() => {
            splashScreen.hide();
        }, 100);
    }      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();

  var notificationOpenedCallback = function(jsonData) {
    alert('notificationOpenedCallback: ' + JSON.stringify(jsonData));
  };

  window["plugins"].OneSignal
    .startInit('opensignal api', 'google sender')
  	.handleNotificationOpened(notificationOpenedCallback)
    .endInit();
    
          this.pages = [
      { title: 'sfd ', component: ServicePage },
      { title: 'dsf', component: OffersPage },
       { title: 'sdfs', component: GalleryPage },
      { title: 'fdsf', component: AboutPage },
       { title: 'fsdf fdsf', component: NotifPage },
      { title: 'fdsf fdsfds', component: ContactPage }
    ];
    });
  }
   openPage(page) {
    // Reset the content nav to have just this page
    // we wouldn't want the back button to show in this scenario
    this.nav.setRoot(page.component, { animate: false });
  
}



}

While I can’t say why you are getting two notifications if it is only registered once, here is how I set it up.

import { OneSignal } from ‘@ionic-native/onesignal’;

constructor(public oneSignal: OneSignal, …

this.platform.ready().then(() => {
this.oneSignal.startInit(‘onesignal api’, ‘google sender’);
this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.InAppAlert);

    this.oneSignal.handleNotificationReceived().subscribe(() => {
      // do something when notification is received
    });

    this.oneSignal.handleNotificationOpened().subscribe(() => {
      // do something when a notification is opened
    });

    this.oneSignal.endInit();

}

the problem still exist
is the any possible solution

Set up another OneSignal app and see if it happens with that one too.
Try a different device.

1 Like

I am not that familiar with Android: What do the two different app (?) icons on the left mean?

1 Like

the notification with bell is show with app notification
they are two notification arrives
not only one thats my problem duplicate push notification

Yes, but why do they have two different icons? What does the “bell” icon mean? Does it belong to a different app? When do notifications show the bell icon instead of the app icon?

1 Like

the bell notification arrives with push notification both belong to the same app

That is impossible, an app can only have one app icon. Or did you set the bell icon for you app somewhere?

I repeat my questions:

i dont now why these icon with bell shows

Do you have some other app that catches notifications? I don’t know if this is a real thing or not.
Have you tried it on another device?

Is it possible that you have renamed the widget id and now you have it installed twice on your device?

sir the push notification with bell show only if app work in background i think this is webview
crosswalk notification how can i disable it

set to none…

this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.None); //How the notification was displayed to the user. Can be set to Notification, InAppAlert, or None if it was not displayed.

1 Like

This may happen because you have two notification handlers in your app, the OneSignal plugin and the Ionic native Push plugin.

The one with the bell is handled by OneSignal, which requires a specific icon file naming.

2 Likes