iOS Notification service for Flutter
Implement the iOS notification service by adding the AcousticMobilePushNotification.xcframework to your App. The AcousticMobilePushNotification.xcframework enables support for media attachments (images, audio, and video).
- Download and unzip a version of the iOS SDK.
- Open your project and the iOS folder in Visual Studio Code.
- Right-click on Runner.xcworkspace file and select Reveal in finder.
- Then open the Runner.xcworkspace file with Xcode.
- Add the Notification Service by selecting Runner, then go to the File menu and select New > Target.
- In the dialog box, select iOS at the top and the Notification Service Extension for the Application Extension.
- Click Next, and a new dialog box opens. Update the following:
a. Add the Product Name for your new target. For example, NotificationService.
b. Choose a language. For example, Swift.
c. Select your project and the application in which you would like to embed the new target.
d. Click Finish to add your new target. - A new dialog appears asking you to activate a new scheme for the Notification Service target. Click Activate. The following are added to your project:
a. A new folder on your project navigator with the Notification Service code.
b. A new Notification ServiceTarget on your main project. - Drag and drop the AcousticMobilePushNotification.xcframework from the unzipped folder to your Notification Service Target's Frameworks and libraries in the General tab.
- In the Signing & Capabilities tab, add two new capabilities to your Notification Service Target:
a. Add the App Group capability to your notification service extension target. Be sure to use the same app group as the main application.
b. Add the Keychain Sharing capability to your notification service extension target. Be sure to use the same value as the main application. - In the Build Settings tab, check that the Other Linker Flags property is set to
-ObjC
on your Notification Service target. - From the main application, select the MCEConfig.json file and add your new Notification Service Target to their Target Membership.
- Since the main project is configured manually using the Config.xml file, you must also manually configure your new Notification Service Extension.
- Apply the following changes to your Notification Service swift file:
a. Import the AcousticMobilePushNotification framework:import AcousticMobilePushNotification
b. Remove all the methods from theNotificationService
class. Instead of subclassing fromUNNotificationServiceExtension
, useMCENotificationService
. - Check the NotificationService.swift file for the following references:
import UserNotifications
import AcousticMobilePushNotification
class NotificationService: MCENotificationService {}
Updated 9 months ago