infobip/mobile-messaging-flutter-plugin

Push notifications on iOS while the app is in the foreground

Closed this issue · 6 comments

Hello,

I am trying to display push notifications on iOS while my app is in the foreground. I added fullFeaturedInAppsEnabled: true to my Configuration object, but the notifications are still not appearing. Could you please provide guidance on how to achieve this.

Hello @Ikami-Mercy ,
in order to have your FullFeatured In-Apps working, you need to have them activated on your account. Can you verify that you have this feature enabled on your account level?

@ikresicc No it's not enabled, what are the steps to enable it?

In order to use this feature you must request it through account manager or support channels. More details about the feature you can find on this page:
https://www.infobip.com/docs/mobile-app-messaging/send-in-app-message#fully-featured-in-app-messages

But just to make sure, are you trying to use FullFeatured In-Apps, or you are trying to send regular message, for example push notifications via the broadcast? Can you verify that, and check that you are not receiving message?

Also, we advise following quick start steps for iOS platform as described here:
https://github.com/infobip/mobile-messaging-flutter-plugin#quick-start-guide

@ikresicc Currently, my organisation only uses infobip for push notifications within the app I'm working on.
The notifications may be triggered while the user is still interacting with the app, so I need to determine whether it is possible to display them while the app is in the foreground using the infobip flutter sdk.

For iOS, notifications only appear when the app is in the background, whereas for Android, notifications work when the app is in both the foreground and background. I had previously come across your documentation stating that this is the default IOS behaviour for the push notification, which is why I set FullFeatured In-Apps to true in my Configuration object when initialising the infobip sdk.

My AppDelegate.swift code is as per the documentation as well:

`import UIKit
import Flutter
import MobileMessaging

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}

MobileMessagingPluginApplicationDelegate.install()
GeneratedPluginRegistrant.register(with: self)

return super.application(application, didFinishLaunchingWithOptions: launchOptions)

}

override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
MobileMessaging.didRegisterForRemoteNotificationsWithDeviceToken(deviceToken)
}

override func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
MobileMessaging.didReceiveRemoteNotification(userInfo, fetchCompletionHandler: completionHandler)
}

// Handle notifications in the foreground
@available(iOS 10.0, *)
override func userNotificationCenter(_ center: UNUserNotificationCenter,willPresent notification: UNNotification,withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert, .sound, .badge,])
}
}`

Ok I understand.

For the case where you want to display push notifications while the app is on the foreground for iOS, you can check this article:

https://github.com/infobip/mobile-messaging-sdk-ios/wiki/How-to-display-messages-when-app-is-running-in-the-foreground%3F

Hello @Ikami-Mercy, seems the question is answered, closing it. Feel free to create another or reopen if you disagree or have other problems with integration