Setting Up - iOS

Quick setup guide how to install our iOS SDK into your application

Prerequisites

  1. Activate your profile & your Notches first. If you need help follow the activation docs
  2. Navigate to Dashboard / [Your application name] / Credentials
Where to find credentials
Where to find credentials
  1. Set up your ~/.netrc file. If you don’t have it, create it now.
    • Copy the credentials from the developer page.
machine wearnotch.com
  login {yourUserName}
  password {yourPassword}

Using with CocoaPods

Our SDK can be accessed only with cocoa pods. If you are unfamiliar with it, please follow this document then return when you are ready.

Installing the latest dependency

Use the following entry in your Podfile:

pod 'WearnotchSDK', :podspec => "https://s3.amazonaws.com/wearnotch-media/public/iOS-Releases/{latest_version_number}.json"
Important changes from v 1.9.0

Due to a mandatory static library you need to manually remove some frameworks from your top pod module.
Copy the following script at the end of your pod file and update your target name properly.

# Remove the static WearnotchSDK libraries from the app target in order to avoid duplicated static library copy
post_install do |installer|
  installer.pods_project.targets.each do |target|
    # Remove only from the main app target
    # IMPORTANT: Insert target name here
    if target.name == "Pods-{YOUR_APP_POD_TARGET_NAME_IN_YOUR_POD_FILE}"
      puts "Updating #{target.name} OTHER_LDFLAGS"
      target.build_configurations.each do |config|
        xcconfig_path = config.base_configuration_reference.real_path

        # read from xcconfig to build_settings dictionary
        build_settings = Hash[*File.read(xcconfig_path).lines.map{|x| x.split(/\s*=\s*/, 2)}.flatten]

        # modify OTHER_LDFLAGS
        build_settings['OTHER_LDFLAGS']['-framework "JRE"'] =  ""
        build_settings['OTHER_LDFLAGS']['-framework "JSR305"'] = ""
        build_settings['OTHER_LDFLAGS']['-framework "WearnotchSDK"'] = ""

        # write build_settings dictionary to xcconfig
        File.open(xcconfig_path, "w")
        build_settings.each do |key,value|
          File.open(xcconfig_path, "a") {|file| file.write("#{key} = #{value}")}
        end
      end
    end
  end
end

Latest version is available in the changelogs

Then use this command in the project directory:

pod install

If you have any problem with the locked Alamofire version, simply remove that line from the Podfile.lock and execute the install again.

Use the generated .xcworkspace from now on.

In any file you’d like to use WearnotchSDK in, don’t forget to import the framework with import WearnotchSDK.

Permissions

Do not forget to specify the following Bluetooth privacy options in your application info.plist file:

<key>NSBluetoothPeripheralUsageDescription</key>
<string>$(PRODUCT_NAME) needs bluetooth access Notches via bluetooth.</string>

<key>NSBluetoothAlwaysUsageDescription</key>
<string>$(PRODUCT_NAME) needs bluetooth access Notches via bluetooth.</string>

Usage

Create a singleton service:

public static let service = try! NotchAPI.Builder().build().service

Good to know If you want to develop your app without using notches it is possible to use a ‘mock’ build of the service. All the service calls will return with success after a short delay. Create a service by setting the ‘isMock’ property to true:

public static let service = try! NotchAPI.Builder()
  .build(isMock: true)
  .service

Prerequisites
Setting Up - Android