Latest release of BearSDK brings many improvements and better practices to make your integration smoother.
General improvements:
- https support.
- removed the most part of external dependencies.
- reduced size of sdk approximately twice.
- optimized unloading resources.
- removed unnecessary debug logs.
- reworked sdk initialization process.
This section describes what steps you need to follow to update your application with the version 2.0 of the BearSDK.
Update dependency version
- Update your dependency manager file
Carthage example
before:
github "Alamofire/Alamofire" "4.5.1"
github "Hearst-DD/ObjectMapper" "3.0.0"
github "ReactiveX/RxSwift" "3.6.1"
github "Swinject/Swinject" "2.1.1"
github "Swinject/SwinjectStoryboard" "1.1.2"
github "marketplacer/keychain-swift" "9.0.2"
github "onevcat/Kingfisher" "4.1.0"
github "realm/realm-cocoa" "v2.10.2"
after:
github "Alamofire/Alamofire" "4.6.0"
github "ReactiveX/RxSwift" "4.1.1"
- update manually
BearSDK.framework
file and removeBearGL.framework
from embedded binaries. Starting version 2.0BearSDK
andBearGL
merged together to simplify integration process.
Embedded Binaries section after update:
Change your application Info.plist:
NSAllowsArbitaryLoads
not mandatory starting version 2.0.
By default BearSDK supports content only through https
. Thats why you have to use only https
in BEAR Frontend.
If you want to support http
at your own risk – you are able to specify NSAllowsArbitaryLoads
key to true
in NSAppTransportSecurity
.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
AppDelegate class
The config1.1.data
asset resource file is not used anymore. You have to use the secret key instead which is provided by BEAR (for development process you can use the sample application one). Use this secret key as parameter in the BearSDK.set(secretKey: String)
method.
You only need to initialize the BearSDK in your AppDelegate
class:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
try! BearSDK.set(secretKey: secretKey)
return true
}
BearSDK
class
The BearApp
class renamed to BearSDK
:
- added:
shared
– Shared instance of BearSDK.set(secretKey:) throws
– Setup secret key to configure BearSDK.destroy
– Destroys all loaded BearSDK resources.preload(_ bearDidLoad: (() -> Void)?)
– Preloads BearSDK resources to reduce loading time ofBearViewController
.isLoaded:
– The status of BearSDK resources.
- changed:
registerDevice(_ deviceToken: Data?)
toregisterDevice(withDeviceToken token: Data)
getDeviceId
todeviceId
- removed:
init?(withUserConfig:)
– useshared
instead.getCameraViewController(onDismiss:, bearLoaded:)
– useBearViewController
instead.getHandler:
– usehandler
property ofBearViewController
instead.setMarkerCallback(_ callback:)
– usedelegate
property ofBearViewController
instead.
BearConfigProtocol
The BearConfigProtocol
does not exist anymore, to setup timeToPause
and scannerColor
you have to use the same properties in BearViewController
.
CameraViewController
class
Since BearApp
was removed and hense getCameraViewCotnroller
method too, you are able to create BearViewController
the way you want. You are able to create instances of BearViewController
subclasses programmaticaly or using Interface Builder and use those objects to provide the specific behaviors and visual appearances that you need.
- Note: You are able to create multiple instances of
BearViewController
or it subclasses, but you are not able to show them simultaneously. And keep in mind that every instance ofBearViewController
or it subclass uses the same view for render. Be careful with view states.
MarkerCallback
The delegate of BearSDK moved from BearApp
class to BearViewController
. Since version 2.0 it is acceptable using delegate
property of BearViewController
.
MarkerCallback
has been renamed to BearDelegate
.
- added:
assetClicked(with assetId:)
– Function will be executed on click of any asset.scannerStateChanged(_ state:)
– Function will be executed when BearSDK Scanner has changed state.reachabilityStatusChanged(_ reachable:)
– Function will be executed on change of reachability status.didFail(withError error:)
– Function will be executed when an error occurs while the BearSDK is loading content.
- changed
noMarkerFound
tomarkerNotRecognized
.
BearHandlerProtocol
The handler of BearSDK features moved from BearApp
class to BearViewController
. Since version 2.0 it is acceptable using handler
property of BearViewController
.
Changed BearHandlerProtocol
:
- added:
scannerState
resumeCamera(animated:)
pauseCamera(animated:)
isFlashEnabled
isNetworkReachable
- changed:
showShare(fromRect rect: CGRect)
totakeScreenshot
– now this function takes screenshot of camera view, ignoring any overlapping UI elements.startScan
tostartScanning
.stopScan
tostopScanning
.showMarkerInFreezedMode(id:)
toshowARSceneWithoutTracking(withMarkerId id:)
.
- removed:
dismiss
– use native dismiss functions instead.clearView
– usecleanView
instead.showMarkerInFreezedMode(targetId:)
– useshowARSceneWithoutTracking(withMarkerId id:)
instead.
New classes
BearError
exposes short description, type and in some cases reason of occured error.type
shortDescription
reason
BearErrorType
describes type of occured error.invalidSecretKey
network
decoding
backend
specific
unknown
BearScannerState
is used to describe possible BearSDK scanner states.idle
scanning
processing
rendering
BearViewController
provides a infrastructure for your application to manage BearScanner.timeToPause
time after that scanner will be paused.scannerColor
scanning line color.disableCameraAutoHandling
disables automatic camera handling.handler
object to control Bear scanner features.delegate
used to receive scanning callbacks.
BearViewControllerObjc
the same asBearViewController
for Objective-C support. Because swift forbids subclasses from swift classes.