Created
July 1, 2021 07:12
-
-
Save fuadarradhi/461536381d3d80d81522e678d9638660 to your computer and use it in GitHub Desktop.
Flutter Test FCM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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