sendPushNotification method
Future<void>
sendPushNotification(
)
Implementation
Future<void> sendPushNotification() async {
final url = Uri.parse('http://localhost:3000/push');
var token = await _firebaseMessaging.getToken();
var data = '''
{
"notification": {
"body": "this is a body",
"title": "this is a title"
},
"priority": "high",
"data": {
"click_action": "FLUTTER_NOTIFICATION_CLICK"
},
"token": "$token",
"topics": "test"
}
''';
final response = await http.post(
url,
headers: <String, String>{
"Content-Type": "application/json",
"Keep-Alive": "timeout=5",
"Authorization": "$token"
},
body: data,
);
if (kDebugMode) {
print(response.statusCode);
}
}