Skip to main content

Push Notifications

Firebase configuration​

To enable push notifications, set up Firebase Cloud Messaging in your own Firebase project and share the credentials with MeetingLawyers:

  1. Create (or open) your Firebase project at Firebase Console and register your iOS app with its Bundle ID.
  2. In Project settings → Cloud Messaging, upload your APNs Authentication Key (.p8) along with your Team ID and Key ID.
  3. Download the GoogleService-Info.plist and add it to your Xcode project. See the Firebase Apple platforms setup guide for adding the Firebase SDK via Swift Package Manager.
  4. In Project settings → Service accounts, click Generate new private key and send the downloaded JSON file to support@meetinglawyers.com (treat it as a credential — keep it out of source control and send it via secure email, e.g. as a password-protected archive).

Firebase Service Accounts

See: Firebase Documentation

Sample: Our example with push notification

Push notifications​

Once the service account is configured, implement push notification handling in your app. Add the following to your AppDelegate.swift:

AppDelegate.swift
@main
class AppDelegate: UIResponder, UIApplicationDelegate {

// Create a class to delegate all push configuration
private let pushNotificationSample = PushNotificationSample()

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
pushNotificationSample.configurePush(application: application)
return true
}
}

Create a dedicated class to handle push configuration:

PushNotificationSample.swift
import FirebaseMessaging
import MeetingLawyers
import UIKit
import FirebaseCore
import Foundation

class PushNotificationSample: NSObject {

public func configurePush(application: UIApplication) {

// Enable firebase push notification
registerFirebasePushNotification()

// Enable Push notification
registerForPushNotifications(application: application)

}
}
PushNotificationSample.swift
extension PushNotificationSample {
internal func registerFirebasePushNotification() {
FirebaseApp.configure()
Messaging.messaging().delegate = self
}

internal func registerForPushNotifications(application: UIApplication) {
UNUserNotificationCenter.current().delegate = self

let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: { _, _ in }
)
application.registerForRemoteNotifications()

}
}

Receive push token:

PushNotificationSample.swift
// MARK: Firebase Implementation
extension PushNotificationSample: MessagingDelegate {

func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
if let fcmToken = fcmToken {
Task {
print("[ApplicationDelegate] Firebase registration token: \(fcmToken)")
do {
try await MeetingLawyersApp.setFirebaseMessagingToken(token: fcmToken)
print("[ApplicationDelegate] Token registered correctly")
} catch {
print("[ApplicationDelegate] Error registering token: \(error)")
}

}
}
}
}

Pass incoming notifications to the SDK:

PushNotificationSample.swift

// MARK: Push notification Implementation
extension PushNotificationSample: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ userNotificationCenter: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
guard MeetingLawyersApp.isMeetingLawyersPush(notification: notification) else {
// Not a MeetingLawyers push — handle it with your own logic
completionHandler([.banner, .badge, .sound])
return
}
_ = MeetingLawyersApp.userNotificationCenter(willPresent: notification.request, completionHandler: completionHandler)
}

func userNotificationCenter(_ userNotificationCenter: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
guard MeetingLawyersApp.isMeetingLawyersPush(notification: response.notification) else {
// Not a MeetingLawyers push — handle it with your own logic
completionHandler()
return
}
_ = MeetingLawyersApp.userNotificationCenter(didReceive: response.notification.request) { error in
// The professional list is not in the navigation: open it, then the chat (see below)
if case .actionFailed(reason: .executionError(let action))? = error {
Task { @MainActor in await self.openOverProfessionalList(action) }
}
completionHandler()
}
}
}

Open the chat from any screen​

The SDK opens the chat of a tapped push only when its professional list is in your app's navigation. When it is not (for example, the user is on one of your screens), it returns actionFailed(reason: .executionError(pendingAction:)) instead. Push the list without animation and run the pending action: the chat opens on top of the list, so going back lands on it.

PushNotificationSample.swift
extension PushNotificationSample {
@MainActor
func openOverProfessionalList(_ action: MeetingLawyersAction) async {
// Your app's navigation controller: the topmost one, or its selected tab's
var top = UIApplication.shared.connectedScenes
.compactMap { ($0 as? UIWindowScene)?.keyWindow?.rootViewController }
.first
while let presented = top?.presentedViewController { top = presented }
guard let navigationController = (top as? UITabBarController)?.selectedViewController as? UINavigationController
?? top as? UINavigationController,
let list = MeetingLawyersApp.professionalListViewController()?.viewControllers.first else { return }
navigationController.pushViewController(list, animated: false)
try? await MeetingLawyersApp.execute(action: action, origin: navigationController)
}
}

MeetingLawyersApp.execute(action:origin:) follows the same rule, so do the same when you open a chat by professional hash from your own screens. The sample does both in MeetingLawyersIntegration.swift.

caution
  • It is necessary that the host application has the necessary permissions and entitlements to receive push notifications.

  • It is essential to provide an Authorization key to the administrator of your MeetingLawyer account so that notifications are received correctly.

  • It is highly recommended to implement background fetch result and modify your app capabilities to include 'fetch' and 'remote-notification' entitlements.

<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>

Next steps​