Skip to content

A React Native wrapper for the native (iOS and Android) Bringg driver SDKs (Including Click & Collect)

License

Notifications You must be signed in to change notification settings

bringg/ReactNativeBringgDriverSDK

Repository files navigation

react-native-bringg-driver-sdk

A React Native wrapper for the native (iOS and Android) Bringg driver SDKs (currently supporting the active customer use case)

Installation

npm install @bringg/react-native-bringg-driver-sdk --save

or

yarn add @bringg/react-native-bringg-driver-sdk

iOS specific installation

  1. Change minimum iOS version to 12. This should be done in the Podfile and on the target in the project settings in Xcode.
  2. Add use_frameworks! to Podfile. When adding use_frameworks!, if you are using Flipper you will need to either disable it or change linking to static libraries. If you can not use use_frameworks! in your Podfile, please see item #6
  3. Perform a pod install
cd ios && pod install && cd ..
  1. Add capabilities and privacy usage description
  2. Set BUILD_LIBRARY_FOR_DISTRIBUTION for Pods required by the BringgDriverSDK
# All dependencies of the BringgDriverSDK needs to be built with the 'BUILD_LIBRARY_FOR_DISTRIBUTION' configuration set to 'YES'
BringgDriverSDKDependencies = [
  'Socket.IO-Client-Swift',
  'Starscream',
  'libPhoneNumber-iOS',
  'GzipSwift',
  'Alamofire',
  'XCGLogger',
  'RealmSwift',
  'ObjcExceptionBridging',
  'Kingfisher',
  'KeychainAccess',
  'DeviceKit'
]

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      if BringgDriverSDKDependencies.include? target.name
        config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
      end
    end
  end
end

  1. (Optional) If you can not use use_frameworks! in your Podfile, please add the following code to your Podfile to configure all Bringg dependencies as dynamic frameworks.
pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
    installer.pod_targets.each do |pod|
      if BringgDriverSDKDependencies.include?(pod.name) 
        def pod.build_type
          Pod::BuildType.dynamic_framework
        end
      end          
    end
  end

Removing Flipper

  1. In the Podfile remove the following from your target
  add_flipper_pods!
  post_install do |installer|
    flipper_post_install(installer)
  end
  1. Remove initialization code of Flipper from AppDelegate.m.

Static library linking to keep Flipper and use_frameworks!

An example of how to keep Flipper working with use_frameworks! exists in /example/ios/Podfile

$static_framework = [
  'FlipperKit',
  'Flipper',
  'Flipper-Folly',
  'CocoaAsyncSocket',
  'ComponentKit',
  'Flipper-PeerTalk',
  'Flipper-RSocket',
  'YogaKit',
  'CocoaLibEvent',
  'openssl-ios-bitcode',
  'boost-for-react-native'
]

pre_install do |installer|
  Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
  installer.pod_targets.each do |pod|
    next unless $static_framework.include?(pod.name)

    def pod.build_type
      Pod::BuildType.static_library
    end
  end
end

Android project configuration

  1. Make sure to set the minSdkVersion to at least 21.
  2. Make sure your app meets Google Play's target API level requirements.

Running the example app

The example app has a basic implementation of expected use case flows. To run it, clone the repo and then do:

yarn #prepares the sdk for the example app

cd example
yarn

# for ios
cd ios && pod install && cd ..
yarn ios

# for android
yarn android

License

Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) More details

Troubleshooting

Build Issue with FBReactNativeSpec

A known issue with React NAtive dependecy. reference:

facebook/react-native#31034

When you get this error:

error: Cycle in dependencies between targets 'BringgDriverSdkIosExample' and 'FBReactNativeSpec'; 
building could produce unreliable results.

On the example app, the solution is to go to the Pods/FBReactNativeSpec target in Xcode, and move the [CP-User] build script above the Headers.

Running with xcode 11.3.1 (iOS)

The Native iOS SDK is precompiled - when using a swift version that is not the latest, you will need to do another step in order to use a native SDK that was compiled with the same Swift version that you are using.

In podfile add to your application target the following pods:

  pod 'BringgDriverSDK', :git => 'https://github.com/bringg/Bringg-iOS-DriverSDK.git', :branch => '1.10.0-xcode-11.3.1'  
  pod 'BringgDriverSDKObjc', :git => 'https://github.com/bringg/Bringg-iOS-DriverSDK.git', :branch => '1.10.0-xcode-11.3.1'

You can see an example of this in /Example/ios/Podfile