The current SDK supports iOS8 and above
MoEngage SDK supports rich notifications for iOS10, and hence uses UserNotifications Framework available from iOS SDK 10 onwards for the same. Upgrade Xcode to version 8 or above to use our iOS SDK version 3.0+
Cocoapods is a dependency manager for Objective C & Swift projects and makes integration easier.
- If you don't have cocoapods installed, you can do it by executing the following line in your terminal.
sudo gem install cocoapods
- If you don't have a Podfile, create a plain text file named Podfile in the Xcode project directory with the following content, making sure to set the platform and version that matches your app.
If you are using use_frameworks! (dynamic framework) then add the code below in your Podfile
use_frameworks! pod 'MoEngage-iOS-SDK' # if using use_frameworks! , add the code below: post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| if target.name == “MoEngage-iOS-SDK" config.build_settings["OTHER_LDFLAGS"] = '$(inherited) "-ObjC"' end end end end
- Install MoEngage SDK by executing the following in the Xcode project directory.
- Now, open your project workspace and check if MoEngage SDK is properly added.
To install manually, follow the steps below:
Download the latest sdk from the following link.
Add the given library file (.a extension) from MoEngageSDK folder to your project.
Add the given header files (.h extensions) from MoEngageSDK folder, by dragging and dropping the files in to your project.
Add the following compiler flag: -ObjC. Select your project. Go to “Build Settings” ->”Linker” ->”Other Linker Flags” and add this flag.
Simply add the MoEngage-iOS-SDK/MoEngage.h and other header files as needed, in your bridging header and you will be good to go.
Here you will have to import the SDK by directly using an import statement as below:
// This will import all the necessary modules including Inbox and Geofence import MoEngage_iOS_SDK
Please note that prior to building for the first time, Xcode may display an error: No such module found ‘MoEngage_iOS_SDK’. Upon your first successful build this error should disappear and MoEngage will be integrated within your Swift app!
If this doesn't work as well, make sure you have made changes to Podfile as mentioned in the CocoaPods section.
Awesome, you are all set to use MoEngage now. Next we will see how to initialize MoEngage SDK and changes that are to be made to your AppDelegate file.