Push Notifications
#
Firebase configurationIn order to enable MeetingLawyers Chat notifications, there are two posibilities:
1.- If you have your own Firebase app declared, you must provide us google-services.json
from your Firebase workspace.
2.- If you don't have a Firebase and don't want to create it, we can provide one. For Android we need your App Package
, and for iOS we need .p8 Certificate file
, Team ID
, and the certificate key
. Once Firebase app are created, we'll provide you google-services.json and GoogleService-info.plist files to add to your apps.
Sample: Our example with push notification
#
Push notificationsMeetingLawyersSDK framework uses push notifications to communicate users pending messages, these notifications are served by Firebase SDK
.
As soon as the on-screen chat presentation starts, if permissions to send notifications have not yet been needed by the host application, the system security dialog is displayed. When the user grants the necessary permissions to send push notifications, it is mandatory to intervene system remote notification calls to notify MeetingLawyersSDK with the new device token. To do so, we require to implement the following methods in your AppDelegate.swift
:
Now create PushNotificationSample class to unify all code and make more clean our code:
Receive push token:
Now, the app can receive chat notifications. After that you must pass notifications to library methods to process the Push Notification info:
#
Handle didReceive errorIf there is any error using func userNotificationCenter(_ userNotificationCenter: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
should be handled and the result redirected.
The SDK can handle the notification only if the top view controller is an instance of ProfessionalListViewController
, MessagesViewController
or ProfileViewController
. If the top view controller is not from the SDK, for example it is one from your application, the method will return an MeetingLawyersError
error.
The error can have one of these values:
actionFailed(reason: ActionFailureReason)
pushesFailed(reason: PushesFailureReason)
And if the value is actionFailed
case, the reason
values of this error are one of the following they can be used in the execute
function:
executionError(pendingAction: MeetingLawyersAction)
The variable of type MeetingLawyersAction
should be saved until an instance of the SDK is rendered as Top ViewController. At this moment you can call the method func execute(action: MeetingLawyersAction, origin: UIViewController?, completionHandler: @escaping (MeetingLawyersError?) -> Void)
to continue with the navigation.
note
If you use Firebase notifications with Certificates
instead Key Authorization
(.p8), you must add the next piece of code:
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.
#
Next steps- Unread Messages Count: Messages Count
- Show professionals list: Professionals List