Skip to content

Instantly share code, notes, and snippets.

@duytq94
Last active December 11, 2020 02:38
Show Gist options
  • Save duytq94/ff2f87e425442e536cc3c89517200437 to your computer and use it in GitHub Desktop.
Save duytq94/ff2f87e425442e536cc3c89517200437 to your computer and use it in GitHub Desktop.
void registerNotification() {
firebaseMessaging.requestNotificationPermissions();
firebaseMessaging.configure(onMessage: (Map<String, dynamic> message) {
print('onMessage: $message');
Platform.isAndroid
? showNotification(message['notification'])
: showNotification(message['aps']['alert']);
return;
}, onResume: (Map<String, dynamic> message) {
print('onResume: $message');
return;
}, onLaunch: (Map<String, dynamic> message) {
print('onLaunch: $message');
return;
});
firebaseMessaging.getToken().then((token) {
print('token: $token');
Firestore.instance
.collection('users')
.document(currentUserId)
.updateData({'pushToken': token});
}).catchError((err) {
Fluttertoast.showToast(msg: err.message.toString());
});
}
@thakersamveg608
Copy link

What is showNotification() function
Is it a user-defined function or pre-defined function?

@Yoruss
Copy link

Yoruss commented Dec 10, 2020

What is showNotification() function
Is it a user-defined function or pre-defined function?

same question here ? Did you get the answer @thakersamveg608 ?

@duytq94
Copy link
Author

duytq94 commented Dec 11, 2020

Hi there, showNotification() is my defined function, it was defined here https://github.com/duytq94/flutter-chat-demo/blob/master/lib/home.dart#L97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment