Closed GimazDo closed 7 months ago
@ValdZX @mirzemehdi Please, any help?
I think this is more about adding deeplink support to library. But I am still checking my options
@GimazDo @Abdelrhman-sbs
This is implemented in library version 0.5.0
.
This is how you can use it:
NotifierManager.addListener(object : NotifierManager.Listener {
override fun onNotificationClicked(data: PayloadData) {
super.onNotificationClicked(data)
println("Notification clicked, Notification payloadData: $data")
}
})
You need to call below platform-specific functions in order to receive payload data properly.
Call NotifierManager.onCreateOrOnNewIntent(intent)
on launcher Activity's onCreate
and onNewIntent
methods.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
NotifierManager.onCreateOrOnNewIntent(intent)
...
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
NotifierManager.onCreateOrOnNewIntent(intent)
}
Call NotifierManager.onApplicationDidReceiveRemoteNotification(userInfo: userInfo)
on application's didReceiveRemoteNotification
method.
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) async -> UIBackgroundFetchResult {
NotifierManager.shared.onApplicationDidReceiveRemoteNotification(userInfo: userInfo)
return UIBackgroundFetchResult.newData
}
For more detailed information you can check PR https://github.com/mirzemehdi/KMPNotifier/pull/20
Please, let me know if there is any issue
On my side (ios impl) onNotificationClicked
callback not get called when app is in background.
I have followed all the conf steps and tried to use UNUserNotificationCenterDelegate
too, but without luck.
Can you confirm that on your side package callback is triggered when app is in background?
@emanuelecastelli yes, when I click notification I get listener callback.
1) Make sure you enabled remote-notificaiton in backgorund modes in XCode. 2) You added this part in ios part
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) async -> UIBackgroundFetchResult {
NotifierManager.shared.onApplicationDidReceiveRemoteNotification(userInfo: userInfo)
return UIBackgroundFetchResult.newData
}
i have done everything.
When app is in foreground, i din't see the notification, but i get every log that i do in native and in cross.
When app is in background, i see the notification at the top, i tap on it but no log is printed out (nor from native nor from cross). The debugger too not get called in xcode (breakpoint set in didReceiveRemoteNotification
).
App simply returns in foreground.
@mirzemehdi can you provide json body that you use for test push notifications? I'm using something like that, playing with apns props, but no way :(
{
"message": {
"token": ".......",
"notification": {
"title": "title",
"body": "Notification from FCM"
},
"apns": {
"headers": {
},
"payload": {
}
}
}
}
Ok, restoring FCM method swizzling resolve the issue: push notifications callbacks now runs correctly
Hi, how can i detect that user clicked on notification?
I need that when I click on a notification, a screen will open depending on the data in the notification.