Skip to content

Instantly share code, notes, and snippets.

@fuadarradhi
Created July 1, 2021 07:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fuadarradhi/461536381d3d80d81522e678d9638660 to your computer and use it in GitHub Desktop.
Save fuadarradhi/461536381d3d80d81522e678d9638660 to your computer and use it in GitHub Desktop.
Flutter Test FCM
void send() async {
await http.post(
Uri.parse('https://fcm.googleapis.com/fcm/send'),
headers: <String, String>{
'Content-Type': 'application/json',
'Authorization': 'key=$serverToken',
},
body: jsonEncode(
<String, dynamic>{
'notification': <String, dynamic>{
'body': 'this is a body',
'title': 'this is a title'
},
'priority': 'high',
'data': <String, dynamic>{
'id': '1',
'status': 'done',
},
'to': await FirebaseMessaging.instance.getToken(),
},
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment