FCM notification not working when app is kill/closed

Just need to implement forceStart:“1” in JSON format and app will be awake from closed app so finally this is my final code with REST API

<===== REST API =====>

 let headers = new Headers();
    headers.append('Content-Type', 'application/json');
    headers.append('Authorization', 'key=' + "**SERVER KEY**");
    let option = new RequestOptions({ headers: headers });
    let body = {
      "data": {
        "title": "TITLE",
        "body": "MSG",
        "forceStart": "1"
      },
      "priority": "high",
      "to": **TOKEN**
    }
    this.http.post('https://fcm.googleapis.com/fcm/send', JSON.stringify(body), option)
      .map(res => res.json())
      .subscribe(data => {
        console.log(data);
        this.autostart.enable();
      });
  }
<===== PusH plugin ====>
const options: PushOptions = {
			android: {
				senderID: '**APP ID**',
				sound: 'true',
				vibrate: true,
				forceShow: "1",
			},
			ios: {
				alert: 'true',
				badge: 'true',
				sound: 'true',
				clearBadge: 'true'
			},
			windows: {}
		};
		const pushObject: PushObject = this.push.init(options);

		pushObject.on('notification').subscribe((notification: any) => {**foreground and background coding**});
		pushObject.on('registration').subscribe((data: any) => {
			console.log('device token -> ' + data.registrationId);			
		});
		pushObject.on('error').subscribe(error => console.error('Error with Push plugin' + error));


	}
5 Likes