I am waiting

Home - I am waiting

Jordan Maulana asked 2 years ago

There is no doubt that this is THE MOST EASIEST IoT platform i ever try..

so i am waiting tutorial for push notification using android or web..

i find difficulties in android because Curl needs to be root, and i don’t really understand your solutions guys.. i am sorry.

keep spirit MESOSFER!

2 Answers
Best Answer
Badrullami Staff answered 2 years ago

Dear Jordan,

If you want to send push notification using web. You can refer this code below :

<?php 

require dirname(__DIR__).'/../vendor/autoload.php';

const ACCESS_TOKEN = "YOUR ACCESS_TOKEN";
const APP_ID = "YOUR APP_ID";
const APP_KEY = "YOUR APP_KEY";

$client = new \GuzzleHttp\Client();

try{
 
 $data = ['title' => 'Hi', 'alert' => 'Thanks for datang'];
 $respPushNotification = $client->request('POST', 'https://api.mesosfer.com/api/v2/push/notification', [
 'json' => ['data' => $data],
 'headers' => ['Authorization' => 'Bearer '.ACCESS_TOKEN, 'X-Mesosfer-AppId' => APP_ID, 'X-Mesosfer-AppKey' => APP_KEY]
 ]);
 
 $createBucket = (string) $respPushNotification->getBody();
 $bucket = json_decode($createBucket);
 print_r($bucket);
}
catch(Exception $e){
 echo $e->getMessage();
}

Please try first, before ask the question. The good programmer is a person that can solve problem by him self.
Thanks.

Jordan Maulana answered 2 years ago

well.. sorry.,
no example on PHP github to push notification. 
thx 4 d answer.

Jordan Maulana replied 2 years ago

https://github.com/mesosfer/Mesosfer-PHP/tree/master/Sample

to avoid further misunderstanding between developers and mesosfer developers, please update the github.

cmiiw 🙂

Your Answer