Once you have installed Bubbl framework, follow the following steps to correctly configure the SDK:
 

1. Add the SDK initialization call inside application:didFinishLaunchingWithOptions: 
       
    [BUMain setupWithKey:@"YOUR_API_KEY" withURLString:@"YOUR_API_DOMAIN"];

   The API key can be retrieved from Company information from Bubbl web campaign application. The API_DOMAIN should be "https://api.bubbl.tech/api" if you're looking to connect to production or "https://uat.api.bubbl.tech/api" for the sandbox environment - unless you have been told differently by our support team. 

2. After the initialization call, if there are any launch options, pass these to Bubbl SDK. These are used to detect whether user is launching the app by pressing a local notification that was fired by Bubbl SDK when the app was not running in the foreground.

    [[BUMain sharedInstance] applicationDidFinishLaunchingWithOptions: launchOptions];

3. Inside the application:didReceiveLocalNotification: you have to forward the UILocalNotification object to Bubbl Framework:
 
[[BUMain sharedInstance] didReceiveLocalNotification: notification];

Note: The origin of the notification does not matter, the framework will be able to identify whether the notification was scheduled by Bubbl Framework.

4. For handling silent push notifications that are used to update Bubbl database, call

[[BUMain sharedInstance] handleRemoteNotificationWithUserInfo:userInfo andCompletionHandler: ^(UIBackgroundFetchResult fetchResult){

//Add your background fetching code here. Anything that you do inside the application:didReceiveRemoteNotification:fetchCompletionHandler:  method. 

handler(UIBackgroundFetchResultNewData);
}];

in your App Delegate application:didReceiveRemoteNotification:fetchCompletionHandler: method.  

Requirement capabilities: Location Updates, Background Fetch and Remote Notifications.

Inside your .plist file, make sure that you define a value for the NSLocationAlwaysUsageDescription key.

5. In the unlikely case that you get a complaint from Itunes Connect about the build architectures, you will have to add a Run Script phase in order to strip out the simulator architecture (i386 and x86_64). Put it after your step to embed frameworks. This script will look into your frameworks folder and it will ensure that only the architectures you are building for are present. This workaround was tested on Xcode 8.3.3 (8E3004b). 


APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
 
EXTRACTED_ARCHS=()
 
for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
 
echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"
 
echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
done