Ahmed Majid
Ahmed Majid


Ahmed Majid

Using onesignal push notifications without backend server

Using onesignal push notifications without backend server

Ahmed Majid's photo
Ahmed Majid
·Feb 12, 2023·

1 min read


You can use onesignal service to send push notifications without using an external server or backend server directly from the mobile app for example, I know it's not the best solution but you can manage to make it work in small apps.

the code below is an example of flutter code:

sendAdNotification() async {
     OneSignal.shared.getDeviceState().then((deviceState) {
       print("OneSignal: device state: ${deviceState?.userId}");

     var sendData = await post(
       headers: <String, String>{
         'Content-Type': 'application/json; charset=UTF-8',
         'Authorization': 'Basic RESTAPIKEY',
       body: jsonEncode(<String, dynamic>
         "app_id": "APPID",//kAppId is the App Id that one get from the OneSignal When the application is registered.

         "filters": [
           {"field": "tag", "key": "KeyNAme", "relation": "=", "value": Id},




         "headings": {"en": "New Ad"},

         "contents": {"en": titleTextEditingController.text},


Share this