Skip to content

Releases: mirzemehdi/KMPNotifier

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

v0.4.0

28 Feb 00:00
30146d5
Compare
Choose a tag to compare

What's Changed

  • Push Notification onPushNotification method is added to listener. by @mirzemehdi in #15

  • Suggestion: Notifications are displayed when app is in Foreground in Android by @koushikvkk in #13

  • Bump Kotlin version to 1.9.22

New Contributors

By default push notification will be shown to the user. But if you want to handle it what to do with notification content yourself when initializing you can pass showPushNotification value as false. You can still get notification content using #onPushNotification listener method. Based on this issue: #13

Android initialization

NotifierManager.initialize(
  configuration = NotificationPlatformConfiguration.Android(
    notificationIconResId = R.drawable.ic_launcher_foreground,
    showPushNotification = true, //set to false to handle notification content yourself
  )
)

Ios initalization

NotifierManager.initialize(
  configuration = NotificationPlatformConfiguration.Ios(
    showPushNotification = true, //set to false to handle notification content yourself
  )
)

New listener method #onPushNotification

NotifierManager.addListener(object : NotifierManager.Listener {
            override fun onNewToken(token: String) {
                println("Push Notification onNewToken: $token")
            }

            override fun onPushNotification(title: String?, body: String?) {
                super.onPushNotification(title, body)
                println("Push Notification notification type message is received: Title: $title and Body: $body")
            }

            override fun onPayloadData(data: PayloadData) {
                super.onPayloadData(data)
                println("Push Notification payloadData: $data")
            }
        })

Full Changelog: v0.3.0...v0.4.0

v0.3.0

17 Feb 09:40
43b1413
Compare
Choose a tag to compare

What's Changed

Remove notification by id - notifier.remove(notificationId)
Remove all notifications - notifier.removeAll()

  • Suggestion. Hide notification by id. by @ValdZX in #10
  • Suggestion: Android current minSDK is 24, can be changed to 21. Add android and iOS support versions to README file by @mehmetakify in #9
  • Android and iOS setting min sdk (android minSdk 21, ios deploymentTarget 14.1) by @mirzemehdi in #11

New Contributors

Full Changelog: v0.2.0...v0.3.0