Skip to content

Releases: mirzemehdi/KMPNotifier

v1.4.0

11 Dec 23:44
82e6de8
Compare
Choose a tag to compare

What's Changed

  • Customize notifications. Kotlin DSL syle, and Notification Image support by @mirzemehdi in #95
  • Adding setListener to set one listener or to remove existing listeners by @mirzemehdi in #94
  • Exposing KEY_URL and mutable to make it customizable by @mirzemehdi in #93
  • Returning null for Firebase get token when exception occurs by @mirzemehdi in #92
  • Bump lib deps by @mirzemehdi in #97

Now you can send notifications in kotlin dsl style, and finally sending images are supported both in android and ios 🎉🥳

in image field you can either pass:

  1. NotificationImage.Url("image url here") (make sure you also add internet permission, because it will need to download image from url)
  2. NotificationImage.File("image file path") (make sure your app has necessry permission to access that image file path to be able to read its contents)

Example code:

val notifier = NotifierManager.getLocalNotifier()
notifier.notify {
  id= Random.nextInt(0, Int.MAX_VALUE)
  title = "Title from KMPNotifier"
  body = "Body message from KMPNotifier"
  payloadData = mapOf(
    Notifier.KEY_URL to "https://github.com/mirzemehdi/KMPNotifier/",
    "extraKey" to "randomValue"
  )
  image = NotificationImage.Url("https://github.com/user-attachments/assets/a0f38159-b31d-4a47-97a7-cc230e15d30b")
}

Full Changelog: v1.3.0...v1.4.0

v1.3.0

30 Sep 14:01
Compare
Choose a tag to compare

What's Changed

  • Adding Firebase push notification sender python code for testing by @mirzemehdi in #77
  • Add an option to initialize by passing Android Context instance by @mirzemehdi in #78
  • Bump dependencies: Kotlin 2.0.20, Koin: 4.0.0 by @mirzemehdi in #79

Full Changelog: v1.2.1...v1.3.0

v1.2.1

08 Aug 13:54
abaa656
Compare
Choose a tag to compare

What's Changed

  • Adding web support (js and wasm targets) by @mirzemehdi in #51
  • Fixing Ios notification bugs by @mirzemehdi in #56
  • Change onPermissionGranted to onPermissionResult(isGranted: Boolean) by @RemcoTaal in #55
  • Bump versions by @mirzemehdi in #58
  • Android deeplink support (send notifications with URI on Android devices) by @mirzemehdi in #60
  • Custom notification sound in android and ios by @mirzemehdi in #61

Breaking Changes

onPermissionGranted is replaced by onPermissionResult(isGranted: Boolean)

Custom notification sound in android and ios:

Add custom notification sound when initializing the library as below:

Android:

soundUri - Custom Notification sound, uri should be converted to String. Default value is null, if null default notification sound will be played. For custom notification sound put notification sound in res/raw directory. See how it is used in sample app: 3708ea8

val customNotificationSound =
        Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + "com.mmk.kmpnotifier.sample" + "/" + R.raw.custom_notification_sound)
    NotifierManager.initialize(
        configuration = NotificationPlatformConfiguration.Android(
            notificationIconResId = R.drawable.ic_launcher_foreground,
            showPushNotification = true,
            notificationChannelData = NotificationPlatformConfiguration.Android.NotificationChannelData(
                soundUri = customNotificationSound.toString()
            )
        )
    )

iOS:

notificationSoundName - Custom notification sound name. Default value is null. If set null, default notification sound will be played. For cusotm notification sound, place the file in the Resources directory of your iOS target. Ensure the file is added to your target's "Build Phases" under "Copy Bundle Resources". See how it is used in sample app: 4b2a90d

NotifierManager.initialize(
        NotificationPlatformConfiguration.Ios(
            showPushNotification = true,
            askNotificationPermissionOnStart = true,
            notificationSoundName = "custom_notification_sound.wav"
        )
    )

Android deeplink support (send notifications with URI on Android devices)

In order to setData for Intent on Android Devices, you just need to put URI value with "URL" key into payloadData (after converting URI toString). If payload data contains value with "URL" key then intent data will be set internally.

Example code:

//Notifier.KEY_URL value is set as "URL" in the library. If payload data contains that key, then its value will be set as intent data.

notifier.notify(
    title = "Title", 
    body = "bodyMessage", 
    payloadData = mapOf(
        Notifier.KEY_URL to "https://github.com/mirzemehdi/KMPNotifier/",
        "extraKey" to "randomValue"
    )
)

New Contributors

  • @RemcoTaal made their first contribution in #55

Full Changelog: v1.1.0...v1.2.1

v1.2.0-alpha02

06 Aug 02:07
Compare
Choose a tag to compare

What's Changed

  • Fixing Ios notification bugs by @mirzemehdi in #56
  • Change onPermissionGranted to onPermissionResult(isGranted: Boolean) by @RemcoTaal in #55

New Contributors

  • @RemcoTaal made their first contribution in #55

Full Changelog: v1.2.0-alpha...v1.2.0-alpha02

v1.2.0-alpha

19 Jul 15:14
4a3c59d
Compare
Choose a tag to compare

What's Changed

In web it can be initialized using new Web configuration

NotifierManager.initialize(
    NotificationPlatformConfiguration.Web(
      askNotificationPermissionOnStart = true,
      notificationIconPath = null
  )
)

Note:
If you are using mac make sure you also allow notifications for browser from system system settings in order to see web notifications

Full Changelog: v1.1.0...v1.2.0-alpha

v1.1.0

08 Jul 20:13
bcca06b
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.0.1...v1.1.0

v1.0.1

23 Jun 11:18
6807e2d
Compare
Choose a tag to compare

What's Changed

  • Fixing Xcode warning: registerForRemoteNotifications must be used from main thread by @mirzemehdi in #41

Full Changelog: v1.0.0...v1.0.1

v1.0.0

05 Jun 18:10
b903239
Compare
Choose a tag to compare

What's Changed

  • Kotlin 2.0.0 support and bumping dependency versions by @mirzemehdi in #35

Full Changelog: v0.6.0...v1.0.0

v0.6.0

29 Apr 23:02
Compare
Choose a tag to compare

What's Changed

  • Ios asking notification permission optioanal at start and exposing permissonUtil by @mirzemehdi in #27
  • Fixing android payload data is always empty onNotificationClicked by @mirzemehdi in #26

New Things

By default in IOS, notification permission will be asked when application starts. But if you want to handle permission yourself whenever you want, then when initializing library you can pass askNotificationPermissionOnStart value as false in IOS configuration.

Ios initalization

NotifierManager.initialize(
  configuration = NotificationPlatformConfiguration.Ios(
    askNotificationPermissionOnStart = false, //Default value is true
  )
)

Also, PermissionUtil class is exposed in commonMain, that you can use as an utility class for asking permission or checking notification permission for ios. You can get it using

val permissionUtil = NotifierManager.getPermissionUtil()
permissionUtil.askNotificationPermission()

However, In Android this function is just a mock. You need to ask permission in Android activity using like below:

val permissionUtil by permissionUtil()
permissionUtil.askNotificationPermission()

⚠️Warning: PermissionUtil is exposed as an experimental as this library doesn't focus around permissions!. It is there just for making things easier if needed

Full Changelog: v0.5.0...v0.6.0

v0.5.0

09 Apr 03:09
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.4.0...v0.5.0