Tips to Design Flutter PHP and Firebase Push Notification

Created At: 2023-02-08 02:00:22 Updated At: 2023-02-09 22:19:44

Here you may follow the tips to desgin Flutter PHP and Firebase push notification. In this assignment you need to desgin a diagram and write pseudo-code. Once you are done you may do the coding and after that you need to do Postman test.

Find me on Twitter @dbestech. You may also find me on Udemy if you are taking this video and audio chat app tutorial.

Hopefully this would help you understand how notification works in real world app. 

Prerequisite

Before you start you need to make sure you have installed Firebase Admin SDK and it's integrated with PHP Laravel framework.

  1. Make sure FlutterLocalNotificationPlugin is installed
  2. Make sure firebase_messaging plugin is installed
  3. Create a class, you may name it anything (I named it FirebaseMessasingHanlder)
  4. In the class initialize FlutterLocalNotificationPlugin 
  5. And then make sure you do request permission 
  6. And then create a static method(name it initialize()) in the class
  7. Inside the method have the code for onMessage 
    FirebaseMessaging.onMessage.listen((RemoteMessage message)){}
  8. And then add for iOS permission
    await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(alert: true, badge: true, sound: true);
  9. for background notification add the below code in the class
    @pragma('vm:entry-point')
    static Future<void> firebaseMessagingBackground(RemoteMessage message) async {
    await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform,);
    }
  10. Call the initialize() method from main.dart from main() function
  11. Make sure you have installed Firebase Admin SDK (in the PHP server side)
  12. Make sure you get device token
  13. Make sure you know other user's to_token variable
  14. Make sure you know your own access_token variable

Steps 

  1. Pass your access_token in the Authorizatoin
  2. Pass other user's to_token in the params
  3. Pass call_type in the params
  4. Make sure your other android emulator is running
  5. Make sure it's notification permission is enabled.

 

Comment

Add Reviews