App is run forever

what did you get in alert?
If you did get any id then try sending push notification now.

I get id.after try to send notifications.Still my device not receive any notifications.and display the err msg on site

The selected segments do not have any users

Are you running your app on real device?

No my app running on emulator

I think that’s why you are not getting push notification.
Try running that on real device.

@ravi_sojitra.It’s work. app is running or Closed.I closed my app and going to app settings->App->No more apps are running.after i send notifications does not receive.why?I need everytime receive notifications

If you force close your app. no app will receive notification.

@ravi_sojitra How to use Rest API for onesignal can u pls help me.

This is how i do it.

    $content = array(
                  "en" =>'notificationDescription'
                  );

    $fields = array(
      'app_id' => "YOUR OneSignal App ID",
      'include_player_ids' => array($device_token), // that id you are getting in alert with getIds function
      'data' => $notificationData, //if you want to send data ,payload
      'contents' => $content,
      'headings'=>array("en"=>'notificationTitle'),
      'android_sound'=>"notification"
    );

    $fields = json_encode($fields);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8',
                           'Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXX')); //you REST API Key from one signal
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

    $response = curl_exec($ch);
    curl_close($ch);
    return $response;

I am using postman . i am getting this err

{
“errors”: [
“app_id not found. You may be missing a Content-Type: application/json header.”
]
}

But i add Content-Type: application/json header. and app_id

Can you share your app_id and device_token and rest api key?
i think you are supplying wrong app id in app_id in $fields array

I refer this link https://documentation.onesignal.com/v3.0/docs/using-postman and my app id is 821e3c9a-aee4-45c7-9b1d-41bb67c9280b

run the code here i gave you.

@ravi_sojitra How can i add icon ? Kindly advice me

where do you want to add icon?

My app is received notification.default notification is bell.i need set to custom notification icon

How are you sending notification?
from PHP or onesignal dashboard?

I send notification using typescript with ionic 2.not PHP.

i need to see your code from where you are sending notification.

Here is my code

import { Component } from ‘@angular/core’;
import { NavController,Platform } from ‘ionic-angular’;
import { OneSignal } from ‘@ionic-native/onesignal’;
import { Http, Response, Headers, RequestOptions } from ‘@angular/http’;
@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
export class HomePage {

constructor(public http: Http,public platform: Platform,private oneSignal: OneSignal,public navCtrl: NavController) {

let headers=new Headers();
headers.append('Content-Type','application/json; charset=utf-8');
headers.append('Authorization','Basic NDJhZDg0NWQtYjM0NS00YzUzLTgwNjktMDgyNThlMmUxNDYy')


let url = 'https://onesignal.com/api/v1/notifications';

let body = { 
	  app_id: "5d4fd62b-b9f8-4e41-9a89-7ea3b18af3de",
	  contents: {"en": "English Message"},
	  included_segments: ["All"]
	};

let options = new RequestOptions({ 
	url:url,
	method: "POST",
	body:body,
	headers:headers

})	
this.http.post(url, body, options).subscribe(d2=>{
	console.log("success");
	console.log(d2)
})

this.platform.ready().then(() => {
	this.oneSignal.getIds().then((ids)=>{
        console.log("USER ID");
        console.log(ids.userId);
      }).catch((e)=>{
        console.log("error")
        console.log(e);
      })
  	this.oneSignal.startInit('5d4fd62b-b9f8-4e41-9a89-7ea3b18af3de','470761651487');

  	this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.InAppAlert);

  	this.oneSignal.handleNotificationReceived().subscribe((d) => {
 		// do something when notification is received
 		console.log("NOTIFICATION RECEIVED");
 		console.log(d);
    });

    this.oneSignal.handleNotificationOpened().subscribe((d1) => {
	  	// do something when a notification is opened
	  	console.log("NOTIFICATOIN OPENED");
	  	console.log(d1);

	});

	this.oneSignal.endInit();
})

}

}