In order to install the SDK, we will use CMPComapiFoundation, a dependency manager for iOS/MacOS projects:
Swift Package Manager (SPM)
- Open your project in Xcode.
- Select File > Add Package Dependencies... from the menu bar.
- Paste the repository URL:
https://github.com/comapi/comapi-sdk-ios-objc-spminto the top-right search bar. - Set your preferred Dependency Rule (e.g., Up to Next Major Version).
- Click Add Package.
- Select
CMPComapiFoundation, assign it to your app target, and click Add Package again.
Now move on to initialising the SDK
Cocoapods
To add the iOS SDK to your Xcode project with CMPComapiFoundation, do the following:
- Add the iOS SDK
# other podfile info
target '*Your-Target*'
use_frameworks!
pod 'CMPComapiFoundation'
end- Install the iOS SDK
$ pod install- Import the iOS SDK in your Objective-C or Swift file
#import <CMPComapiFoundation/CMPComapiFoundation.h>import CMPComapiFoundationAPNS Environment setup
It is important to ensure your app builds are setup correctly for APNS, so that our SDK can detect whether to use the sandbox APNS (for development builds) or the production APNS (for production, ad-hoc distribution or test-flight builds).
Failure to set the APNS environment correctly for a build will result in no pushes being received!
Development builds push setup
During development, a Apple provisioning profile will be used to sign and deploy your app to a handset. To ensure push works with your app, ensure the following:
- Your app provisioning profile includes the Push Notification entitlement
- You have uploaded a the correct p8 (private key) to Dotdigital, supplied the correct Bundle identifier for your app, Apple team ID and private key ID.
- Your iOS XCode projects build settings must have the Preprocessor Macro of DEBUG=1 in it's build settings, as follows:
- Swift based projects you add it by doing:
- Open your Project Build Settings and search for Swift Compiler – Custom Flags … Other Swift Flags
- Add -DDEBUG to the Debug section
- Add -DRELEASE to the Release section
- For Objective-C based projects:
- Open your Project Build Settings and search for Preproccessor Macros
- Add DEBUG=1 to the Debug section
- Add DEBUG=0 to the Release section
- Swift based projects you add it by doing:
- You have included an entitlements file in your app with the following entry:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
</dict>
</plist>App Store / Adhoc distribution / Test-flight builds push setup
For any other build type other than development you will need to ensure the following are all correct:
- Your app provisioning profile includes the correct Push entitlement
- You have uploaded a the correct p8 (private key) to Dotdigital, supplied the correct Bundle identifier for your app, Apple team ID and private key ID.
- Your iOS XCode project must have the compiler Preprocessor Macro of DEBUG=0 in it's build settings or not defined, otherwise the SDK will register to use APNS sandbox instead of APNS production! To do this:
- Swift based projects you add it by doing:
- Open your Project Build Settings and search for Swift Compiler – Custom Flags … Other Swift Flags
- Add -DDEBUG to the Debug section
- Add -DRELEASE to the Release section
- For Objective-C based projects:
- Open your Project Build Settings and search for Preproccessor Macros
- Add DEBUG=1 to the Debug section
- Add DEBUG=0 to the Release section
- Swift based projects you add it by doing:
- The entitlements file in your app has the following entry:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>production</string>
</dict>
</plist>Now move on to initialising the SDK