Installation
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
To integrate Hyber into your Xcode project using CocoaPods, specify it in your Podfile:
platform :ios, ‘8.0’ use_frameworks! pre_install do |installer| # workaround for https://github.com/CocoaPods/CocoaPods/issues/3289 def installer.verify_no_static_framework_transitive_dependencies; end end pod ‘Hyber/Inbox’, :git => ‘https://github.com/GMSLabs/Hyber-SDK-iOS.git’, :tag => ‘0.1.2’
Then, run the following command:
$ pod install
Add files
Add HyberFirebaseMessagingDelegate.swift file to your project
Configure target
Disable bitcode (set ENABLE_BITCODE to false) in build settings for your target. See Google Cloud Messaging issue
Modify AppDelegate
Add import statement
import Hyber
In func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool add following
Hyber.register( applicationKey: “Your Global Message Service Key”, firebaseMessagingHelper: HyberFirebaseMessagingDelegate.sharedInstance, launchOptions: launchOptions)
This method returns HyberPushNotification if remote or local notification was found in passed launchOptions parameter, nil otherwise, so you can use if like this: let pushNotification = Hyber.register(…)
In func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) add following
Hyber.didRegisterForRemoteNotificationsWithDeviceToken(deviceToken)
In func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) add following
Hyber.didReceiveRemoteNotification(userInfo) completionHandler(.NewData)
Register your application for Remote Notification
Certificates
Configure push-notifications in Certificates, Identifiers & Profiles section of Apple Developer Member Center (manual)
Registering for Remote Notifications
Register your application to receive remote push-notifications (manual)
Don’t forget add Push Notifications for your target (see Capabilities tab). And add turn on Background Modes, whith Remote Notifications flag ON)
Usage
To start using Hyber framework you should provide correct subscriber e-mail & phone (optionally)
Subscriber information
Add
To add new subscriber you should call
Hyber.addSubscriber( phone: UInt64, email: String?, completionHandler: ((HyberResult
In completion handler result you will get Hyber subscriber ID if success
Edit
To edit subscriber information you should call
Hyber.updateSubscriberInfo( phone: UInt64, email: String?, completionHandler: ((HyberResult
In completion handler result you will get success Bool flag
Update subscriber’s location
Hyber.updateSubscriberLocation( location: CLLocation?, completionHandler: ((HyberResult
Update subscriber’s changed Firebase Messaging token (managed by HyberFirebaseMessagingDelegate)
Hyber.updateFirebaseMessagingToken( token: String?, completionHandler: ((HyberResult
Update subscriber can receive push-notifications flag (managed by HyberFirebaseMessagingDelegate)
Hyber.allowRecievePush( allowPush: Bool, completionHandler: ((HyberResult
Get delivered messages
To fetch delivered messages call
Hyber.fetchMessages( forDate: NSDate, completionHandler: ((HyberResult<[HyberMessageData]>) -> Void)? = .None)
Example
let someDate = NSDate() Hyber.fetchMessages(forDate: someDate) { result in guard let messages = result.value else { return } // you code goes here }
How to get keys, push-notifications, IDs
Hyber application key
Contact Global Message Services
Firebase Messaging (push-notifications)
Create new project in Firebase console.
Add iOS aaplication into your project.
Enable Cloud Messaging API for you project in Go to project Settings, switch to Cloud Messaging tab. Upload APNs certificates (Manual).
Than download GoogleService-Info.plist from General tab (Firebase console, project settings).
Add this file to yours application project.
License
3rdparties
XCGLogger by Dave Wood. MIT license
Latest podspec
{ “name”: “Hyber”, “version”: “2.2.4”, “summary”: “Hyber SDK for IOS”, “description”: “TODO: Hyber SDK for IOS. Implement push notification and other Hyber functionality.”, “homepage”: “https://github.com/Incuube/Hyber-SDK-iOS”, “license”: { “type”: “MIT”, “file”: “LICENSE” }, “authors”: { “Taras Markevych”: “[email protected]” }, “source”: { “git”: “https://github.com/Incuube/Hyber-SDK-iOS.git”, “tag”: “2.2.4” }, “platforms”: { “ios”: “9.0” }, “source_files”: “Hyber/Classes/**/*”, “dependencies”: { “Alamofire”: [ “~> 4.4.0” ], “Firebase/Core”: [ “3.11” ], “Firebase/Messaging”: [ “3.11” ], “RealmSwift”: [ “2.6.1” ], “RxSwift”: [ “3.4.0” ], “SwiftyJSON”: [ “3.1.4” ], “CryptoSwift”: [ “0.6.8” ] }, “pushed_with_swift_version”: “3.0” }
Sat, 22 Apr 2017 03:40:09 +0000