mirzemehdi / KMPNotifier

Kotlin Multiplatform Push Notification Library targetting android, iOS, Desktop and Web (JS and Wasm)
http://mirzemehdi.com/KMPNotifier/
Apache License 2.0
340 stars 19 forks source link

Disabling ContextInitializer in Android if needed. Add an option to initialize by passing Android Context instance #63

Closed mirzemehdi closed 1 month ago

mirzemehdi commented 3 months ago
          @mirzemehdi what do you think about making ContextInitializer public? I think some app have to use manual startup initialization logic (my app included). Maybe having an option to do so would be good?

Originally posted by @linhvnguyen9 in https://github.com/mirzemehdi/KMPNotifier/issues/53#issuecomment-2266379524

mirzemehdi commented 1 month ago

This is implemented in 1.3.0 version.

By default using androidx-startup Context instance is obtained automatically in android. But if you disabled androidx-startup, you can pass android Context instance using initialize method as below:


class MyApplication : Application() {
   override fun onCreate() {
       super.onCreate()
       NotifierManager.initialize(
           context = this
           configuration = NotificationPlatformConfiguration.Android(
               notificationIconResId = R.drawable.ic_launcher_foreground,
               showPushNotification = true,
           )
       )
   }
}