PatilShreyas / FCM-OnDeviceNotificationScheduler

Demo implementation to Schedule FCM Notifications on Android Device using AlarmManager + WorkManager.
MIT License
118 stars 28 forks source link

Possible Using Postman ? #7

Open shoppingdev-tech opened 3 years ago

shoppingdev-tech commented 3 years ago

i'm working on alarm Api, here i need to send notification on Perticuler time it is not working ? it is possible Using Api ?

shoppingdev-tech commented 3 years ago

Here is my code to send push notification

public function sendPushNotification($fcm_token, $title, $message, $time) {
    $notification = array('title' => $title, 'text' => $message, 'sound' => 'default', 'badge' => '1', 'isScheduled' => 'true',
        "scheduledTime" => $time);
    $msg = array('to' => $fcm_token, 'notification' => $notification, 'priority' => 'high');
    $server_key = env("SERVER_KEY");
    $headers = array(
        "Authorization: key= $server_key",
        "Content-Type: application/json"
    );
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send');
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($msg));
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}
PatilShreyas commented 3 years ago

Yes it's possible

shoppingdev-tech commented 3 years ago

i'm adding alarm using postman but not showing in local on particular time. its show direct when I run api

shoppingdev-tech commented 3 years ago

any changes from my code ? @PatilShreyas

shoppingdev-tech commented 3 years ago

bhai please answer dede @PatilShreyas

PatilShreyas commented 3 years ago

Did you tested the current implementation using POSTMan first? If you do so, you can be sure about its implementation from the Android side as well