Ionic Native Push Question


#1

Hey Guys,

I am trying to get this working https://ionicframework.com/docs/native/push/

With FireBase Cloud Messaging

Here is the code

import { Push, PushObject, PushOptions, AndroidPushOptions, IOSPushOptions } from '@ionic-native/push';

pushsetup() {
    const options: PushOptions  = {
     
	 android: {
         senderID: '**********',
		 icon: "notification",
		 iconColor: "blue",
		 sound: true,
		 vibrate: true,
		 forceShow: true
     },

     ios: {
         alert: true,
         badge: true,
         sound: true
     },
  
  };
   
  const pushObject: PushObject = this.push.init(options);
 
  pushObject.on('notification').subscribe((notification: any) => {
    if (notification.additionalData.foreground) {
      let youralert = this.alertCtrl.create({
        title: 'New Push notification',
        message: notification.message
      });
      youralert.present();
    }
  });
 
  pushObject.on('registration').subscribe((registration: any) => {
     //do whatever you want with the registration ID
  });
 
  pushObject.on('error').subscribe(error => alert('Error with Push plugin' + error));
  }

Unfortunately there is still no custom icon or sound or vibration :frowning:

I copied the notification png, basically everywhere now in the android/res folder :slight_smile:

Has anyone had any success with this? Do you actually have to use the AndroidPushOptions import anywhere?


#2

Hi,
Well I use heavily objects and Firebase now, but not with notification service, but honestly i never tried notifications.
Your code seems very clean and good, something bothers me with it, but i can’t put a finger on it (I guess it’s not suited for notifications service).
Have fun with Ionic,

UPDATE: ok show the Template View please?


#3

I’ll have to go sorry, have fun theliosc :slight_smile:


#4

Solved it by putting this in the config xml:

<preference name="android-targetSdkVersion" value="20" />

No idea why you need it but no more white icons :slight_smile: