Swift SDK
Last updated
Last updated
Bird Swift SDK is a single integration point to bring the power of BirdCRM in building connected user experience to your application.
Using Bird Swift SDK, you get access to:
Collect Contacts
Send Push Notifications
Integrating Bird Swift SDK into your application consists of the following steps:
Step 1: Add Bird Swift SDK dependency
Step 2: Set Application Key, App Group & Keychain Group
Step 3: Add Capabilities
Step 4: Create AppDelegate
Step 5: Create Notification Service Extension
Step 6: Create Notification Content Extension
Step 7: Create App Group & Keychain Group
You can add Bird Swift SDK as a dependency to your project using Swift Package Manager
In your application in Xcode. Go to File > Add Packages Dependencies to add a new dependency.
Specify the URL of the Bird Swift SDK .
Select the swift-sdk
package and click "Add Package"
All configuration for Bird Swift SDK can be set up in Info.plist
file in your application.
Inside Info.list
file, add an entry for Bird
with type Dictionary
.
Then add the following fields with type String
inside the Bird
dictionary
ApplicationKey: You can get the value of this application key from "Bird Dashboard / Preferences / Applications".
Info.plist
should look like this:
These values need to be added to the Info.plist
file for each of the following:
The iOS application target
Open your application project in XCode.
Select your project in XCode
Select the target of your project under TARGETS
Go to Signing and Capabilities
tab
Click on + Capability
and add the following Capabilities:
Push Notifications
Background Modes
From Background Modes
section, select Remote notifications
You may already have an AppDelegate. If not, you need to create one like in the example below.
Notice that:
instance of Bird
is created once and saved in a static member
bird.notifications.registerDevice
is called inside the method with argument didRegisterForRemoteNotificationsWithDeviceToken
bird.notifications.applicationDidReceiveRemoteNotification
is called inside the method with argument didReceiveRemoteNotification
bird.notifications.willPresentNotification
and bird.notifications.didReceiveResponse(response)
are called from the corresponding methods of UNUserNotificationCenterDelegate
Then you need to use this class as your application delegate. In case you use Swift UI, here is an example:
Add a Notification Service Extension to your project.
Select File > New > Target in Xcode.
Select the Notification Service Extension target from the iOS > Application section.
Click Next.
Specify a name and other configuration details for your app extension.
Click Finish.
Then change the code in NotificationService.swift to only extend from BirdNotificationService
as follows:
Add a Notification Content App Extension to Your Project
Select File > New > Target in Xcode.
Select Notification Content Extension from iOS Application Extension.
Click Next.
Provide a name for your app extension.
Click Finish.
Then go ahead and do the following steps:
Remove the storyboard file from the extension
Remove the NSExtensionMainStoryboard
entry from the extension's Info.plist.
Add a new entry of NSExtensionPrincipalClass
to the Info.plist under NSExtension
. The value should be $(PRODUCT_MODULE_NAME).NotificationViewController
Change the value for entry UNNotificationExtensionCategory
to be BIRD
Change NotificationViewController.swift
to only extend BirdNotificationViewController
as follows:
Select your project in XCode
Select the target application of your project under TARGETS
Go to Signing and Capabilities
tab
Click on + Capability
and add the following Capabilities:
App Groups
Background Modes
Keychain sharing
Inside App Groups
section:
add a new App Group if needed
Select an App Group for this target
Inside Keychain Sharing
section:
Add a new Keychain Group (usually it has the same equals to bundle id of the main target of the app)
Do the same process of adding App Groups and select the same App Group for:
Notification Service Extension target
Notification Content Extension target
The iOS application target
Notification Service Extension target
Notification Content Extension target
AppGroup: This is the name of the app group you will create in .
AccessGroup: This is a name of the access group for keychain sharing you will create in . Usually it has the following format: {TEAM_ID}.{KEYCHAIN_GROUP}
.
Notification Service Extension target. See .
Notification Content Extension target. See
Remember to add Bird
configuration to Info.plist
of Notification Service Extension target as explained in .
Remember to add Bird
configuration to Info.plist
of Notification Content Extension target as explained in .
The go ahead and add the AppGroup
and AccessGroup
to the Info.plist
as explained in for each of the following:
You can find examples and report issue on the public repository .