How to send scheduled push notifications using REST API?
sendFSM() async {
const postUrl = 'https://fcm.googleapis.com/fcm/send';
Map<String, dynamic> data;
String time =
Timestamp.fromDate(DateTime.now().add(const Duration(minutes: 1)))
.millisecondsSinceEpoch
.toString();
data = {
"registration_ids": [
"dqR9vyp4R2W9keBUKdd66a:APA91bEuSc8r3bhjz0oZsA9uiM9-SyIttNgnJIujhB7K9OoqXNGFb5doim0CAyXCYRnAreIP5KUAWLLf3Fn6jzD_qptHfgxbZT5dGR75ntAiw-hqoxQTWG2RTei5IIYnOY46ECzLv-QW"
],
"collapse_key": "type_a",
"notification": {
"title": "title",
"body": "body",
"event_time": time,
},
'data': {
"title": "title",
"body": "body",
"event_time": time,
},
};
final response =
await http.post(Uri.parse(postUrl), body: json.encode(data), headers: {
'content-type': 'application/json',
'Authorization':
"Key=AAA*****************************FCsxhvLO6C7XYCAI-rfPURYBp"
});
print(response.body);
if (response.statusCode == 200) {
return true;
} else {
return false;
}
}
Result: When I am sending this request I am getting a notification immediately in my system tray. Expected: Receive notification after 1 min as per the code written.