Push Notification - GluedIn
Push Notification Integration document
Android Step to Integrate push notification in the parent app
  • Firebase integration document:
    Below are the step-wise integration detail:
    • Create a firebase project on : https://console.firebase.google.com/
    • Now Register your app with Firebase
      • Go to the Firebase console
      • In the center of the project overview page, click the Android icon or Add app to launch the setup workflow.
      • Enter your app's package name in the Android package namefield.
      • (Optional) Enter other app information: App nickname and Debug signing certificate SHA-1.
      • Click Register app.
    • Add a Firebase configuration file
      • Download and then add the Firebase Android configuration file (google-services.json) to your app:
        • Click Download google-services.json to obtain your Firebase Android config file.
        • Move your config file into the module (app-level) root directory of your app.
      • To make the values in your google-services.json config file accessible to Firebase SDKs, you need the Google services Gradle plugin
        • In your root-level (project-level) Gradle file (/build.gradle), add the Google services plugin as a buildscript dependency:
          				buildscript {
          
              repositories {
                // Make sure that you have the following two repositories
                google()  // Google's Maven repository
                mavenCentral()  // Maven Central repository
              }
          
              dependencies {
                ...
          
                // Add the dependency for the Google services Gradle plugin
                classpath 'com.google.gms:google-services:4.3.15'
              }
          }
          
          allprojects {
            ...
          
            repositories {
              // Make sure that you have the following two repositories
              google()  // Google's Maven repository
              mavenCentral()  // Maven Central repository
            }
          }
          				
        • In your module (app-level) Gradle file (usually //build.gradle), add the Google services plugin:
          				plugins {
              id 'com.android.application'
          
              // Add the Google services Gradle plugin
              id 'com.google.gms.google-services'
              ...
          }
          				
          				
    • Add Firebase SDK in your app
      • In your module (app-level) Gradle file (usually //build.gradle), add the dependencies for the Firebase products that you want to use in your app. We recommend using the Firebase Android BoM to control library versioning.
        					dependencies {
          // Import the Firebase BoM
          implementation platform('com.google.firebase:firebase-bom:31.4.0')
          // When using the BoM, you don't specify versions in Firebase library dependencies
        }
        
        Note: By using the Firebase Android BoM, your app will always use compatible versions of Firebase Android libraries.
        					
        					
      • After adding the dependencies for the products you want to use, sync your Android project with Gradle files.
    • Create a service class which must extend FirebaseMessagingService class.
        func registerForPushNotifications() {
       open class MyFirebaseMessagingService: FirebaseMessagingService() {
      
          override fun onNewToken(token: String) {
              super.onNewToken(token)
          }
      
          override fun onMessageReceived(remoteMessage: RemoteMessage) = Unit
      }
        
        
    • Register the service into AndroidManifest.xml file.
    • Within the application component, metadata elements to set a default notification icon and color. Android uses these values whenever incoming messages do not explicitly set icon or color. android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_stat_ic_notification" android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/colorAccent"
    • Now call the setFCMToken() method of GluedInInitializer class in Main Activity of your app.
    • Also call the setFCMToken() method of GluedInInitializer class in MyFirebaseMessagingService service class.
      open class MyFirebaseMessagingService: FirebaseMessagingService() {
      
          override fun onNewToken(token: String) {
              super.onNewToken(token)
              setFCMToken(token)
          }
      
          override fun onMessageReceived(remoteMessage: RemoteMessage) = Unit
      }
      	   
    • Call navigateToFCM() method of GluedInInitializer class in the onMessgeReceived() method of MyFirebaseMessagingService service class
      open class MyFirebaseMessagingService: FirebaseMessagingService() {
      
          override fun onNewToken(token: String) {
              super.onNewToken(token)
              setFCMToken(token)
          }
      
          override fun onMessageReceived(remoteMessage: RemoteMessage) {
              if (remoteMessage.data.isNotEmpty()) {
                  navigateToFCM(remoteMessage.data, this)
              }
          }
      }
      	   
    Prevent auto initialization:
    • When an FCM registration token is generated, the library uploads the identifier and configuration data to Firebase. If you prefer to prevent token autogeneration, disable Analytics collection and FCM auto initialization (you must disable both) by adding these metadata values to your AndroidManifest.xml: android:name="firebase_messaging_auto_init_enabled" android:value="false" android:name="firebase_analytics_collection_enabled" android:value="false"