Push notification with ionic Push


#1

I do folow instruction of ionic for push notification but not work


my code :

import { CloudSettings, CloudModule } from '@ionic/cloud-angular';
import {
  Push,
  PushToken
} from '@ionic/cloud-angular';

const cloudSettings: CloudSettings = {
  'core': {
    'app_id': '5bb9a616',
  },
  'push': {
    'sender_id': '482738418736',
    'pluginConfig': {
      'ios': {
        'badge': true,
        'sound': true
      },
      'android': {
        'iconColor': '#343434'
      }
    }
  }
};
@Component({
  selector: 'signup',
  templateUrl: 'signup.html'
})
export class SignupPage implements OnInit {



  constructor(private http: Http, public navCtrl: NavController, public loadingCtrl: LoadingController, public toastCtrl: ToastController,
    private storage: Storage, private platform: Platform, private geolocation: Geolocation, public push: Push) {



    this.push.register().then((t: PushToken) => {
      return this.push.saveToken(t);
    }).then((t: PushToken) => {
      console.log('Token saved:', t.token);
    }); this.push.rx.notification()
      .subscribe((msg) => {
        alert(msg.title + ': ' + msg.text);
      });
  }



  
  }

who do folow this instruction work plz help me . thanks for reading!


#2

Do you get a token?
Where and how are you testing?

Post your ionic info output please.


#3

i testing on my phone
how to get a token . thansk for your answer


#4

Please plugin following flag:
npm install @ionic/cloud-angular --save

then,

import {
Push,
PushToken
} from ‘@ionic/cloud-angular’;

this.push.register().then((t: PushToken) => {
return this.push.saveToken(t);
}).then((t: PushToken) => {
alert(t.token);
console.log(‘Token saved:’, t.token);
});


#5

i did folow like that but it not work


#6

it’s working perfectly to me. what type of code do you use?