- Clone or download the contents of repository.
- Copy DataLinker.framework file from DataLinkerAPI Framework directory to your xcode project. You can jus drag&drop it there but make sure that Copy items if needed is checked.
- In your target's or project's Build settings, under Other Linker Flags, add -lz entry if it does not exists.
- In your target's General section scroll down to the bottom, and make sure that DataLinker.framework is in Embeded binaries. If its not there, add it.
- In your target's Info section scroll down to section URL Types, expand it and tap + button to add new URL type. Specify your desired URL type identifier and URL scheme. This, newly created URL scheme will be used by DataLinkerAPI to communicate between your app and DataLinker Server app.
- In your project's info.plist file add datalinker to LSApplicationQueriesSchemes array, or simply add these lines of code:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>datalinker</string>
</array>
- Implement
- (BOOL)application:openURL:options:method in AppDelegate to receive response from DataLinker Server app. How that should be handled you can see in our example application. It is also described in User guide. - Thats it. You're about good to go. Please check our User guide and example application for API usage examples.
First thing you need to do in your app to start using DataLinkerAPI is tell API about your callback URL scheme. This is the scheme that you should've created in 5th step of installation guide. You can do it this way:
[DataLinkerAPI setCallBackScheme:@"YourCallbackScheme"];
The connection will be handled by DataLinker Server app, but the data will be streamed to your app. To do that you need to call +(void)connect method of DataLinkerAPI. It will switch to DataLinker Server app, and once the connection is estabilished it will return to your app.
[DataLinkerAPI connect];
As described in point 2 of User guide, after the connection is estabilished DataLinker Server returns to your app. But for DataLinker Server to be able to do that you have to implement - (BOOL)application:openURL:options: method of your AppDelegate, and return true.
Before returning true you have to either save the value of URL that was passed as a parameter to this method, or pass it to some method of some class that will handle DataLinker connection.
After you have that URL at the place you need it to be, you should call +(DataLinker*)handleResponseURL:(NSURL*)url method of DataLinkerAPI.
If the response states that successful connection was estabilished, it will return you DataLinker object, which will provide you with data, if no, it will return nil.
DataLinker *dataLink = [DataLinkerAPI handleResponseURL:receivedURL];
if (dataLink) {
//Connection was successful
} else {
//Either the connection was unsuccessful or the user disconnected from DataLinker.
}
P.S. Please keep the reference of returned DataLinker object, because you will need it later.
To receive data of DataLinker object that you received from DataLinkerAPI method described in point 3 of this User guide, you have to conform to DataLinkerDelegate protocol, and set an object of class that comforms to that protocol as a delegate of DataLinker object.
dataLink.delegate = self;
P.S. Protocol description can be found in DataLinker.framework/Headers/DataLinkerDevice.h.
To disconnect from DataLinker you have to call +(void)disconnect method of DataLinkerAPI. It wil switch to DataLinker Server app, disconnect from connected DataLinker and return to your app with disconnection response.
Because our framework is built so that you could run it on both, real device and simulator, it contains x86_64 architecture which is unsupported in appstore builds, while validating your binary you could get errors like these:
The solution would be to add new Run Script phase to your target, which would scan the frameworks, and remove architectures that are not needed for AppStore build. We provide you the script that does that below, but you might want to change it according to your needs.
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
If you still have questions, please either review our example application, or send me a letter to julius@xplicity.com.
