Push Notification alert title shows index.html


#1

So, this is the first time I’ve implemented Push via ionic.io and phonegap-plugin-push. As you can see from the image, pushes are being received but titled as “index.html”

Would like to change that to something else, but can figure out where it’s defined.

In my app.component.ts constructor:

this.platform.ready().then( () => {
  		    this.push.register().then((t: PushToken) => {
		      return this.push.saveToken(t);
		    }).then((t: PushToken) => {
		      console.log('Token saved:', t.token);
		      console.log('Start listening to push notifications..');
		      this.startListeningForNotifications();
		    });
    });

&

startListeningForNotifications() {
	    this.push.rx.notification()
	    .subscribe((msg) => {
	      alert(msg.title + ': ' + msg.text);
	    });
	}

In app.module.ts:

const cloudSettings: CloudSettings = {
  'core': {
    'app_id': 'my_app_id',
  },
  'push': {
    'sender_id': 'my_sender_id',
    'pluginConfig': {
      'ios': {
        'badge': true,
        'clearBadge': true,
        'sound': true
      },
      'android': {
        'iconColor': '#343434',
        'clearBadge': true,
      }
    }
  }
};

Any pointers?


#2

I’m curious about this as well. Same problem, and I can’t figure out where it’s coming from. I added title: “app name” in the Cloudsettings definition, but that only showed up as msg.title in the line alert(msg.title + ': ’ + msg.text)

Where is the index.html coming from?


#3

alert() is always “index.html”. You have to use another interface element where you can set the title like AlertController: https://ionicframework.com/docs/api/components/alert/AlertController/


#4

Sujan12: Thanks so much!

Just in case someone follows with the same question, I pasted the code I used below that gives results similar to the code posted in the ionic services ‘post’ section.

This is what I used:


this.push_ionic.rx.notification()
        .subscribe((msg) => {
             //alert(msg.title + ': ' + msg.text);
             let alert = this.alertCtrl.create({
             title: 'MyApp',
             subTitle: msg.title,
             message: msg.text,
             buttons: ['Dismiss']
          });
          alert.present();
        });