diff --git a/lib/main.dart b/lib/main.dart index 102d8f6..3be2661 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -58,15 +58,16 @@ Future _setUpNotifications() async { print('on launch $message'); }, ); - - _firebaseMessaging.getToken().then((token) { - print("Firebase Messaging Token: " + token); - - Firestore.instance - .collection("insta_users") - .document(currentUserModel.id) - .updateData({"androidNotificationToken": token}); - }); + if (currentUserModel != null) { + _firebaseMessaging.getToken().then((token) { + print("Firebase Messaging Token: " + token); + + Firestore.instance + .collection("insta_users") + .document(currentUserModel.id) + .updateData({"androidNotificationToken": token}); + }); + } } }