项目作者: matchmore

项目描述 :
iOS SDK
高级语言: Swift
项目地址: git://github.com/matchmore/ios-sdk.git
创建时间: 2017-07-17T15:10:55Z
项目社区:https://github.com/matchmore/ios-sdk

开源协议:MIT License

下载


Matchmore iOS SDK

Matchmore is a contextualized publish/subscribe model which can be used to model any geolocated or proximity based mobile application. Save time and make development easier by using our SDK. We are built on Apple Core Location technologies and we also provide iBeacons compatibility.

Versioning

SDK is written using Swift 4.1.

Matchmore SDK requires iOS 9+.

Installation

Matchmore is available through CocoaPods, simply add the following
line to your Podfile:

  1. pod 'Matchmore'

In case of any problems with cocoapods try

  1. pod repo update

Usage

Please refer to documentation “tutorial” to get a full explanation on this example:

Setup application API key and world, get it for free from http://matchmore.io/.

  1. func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  2. let config = MatchMoreConfig(apiKey: "YOUR_API_KEY")
  3. Matchmore.configure(config)
  4. return true
  5. }

Create first device, publication and subscription. Please note that we’re not caring about errors right now.

  1. Matchmore.startUsingMainDevice { _ in
  2. let publication = Publication(topic: "Test Topic", range: 20, duration: 100, properties: ["test": "true"])
  3. Matchmore.createPublicationForMainDevice(publication: publication, completion: { _ in
  4. print("🏔 Created Pub")
  5. })
  6. let subscription = Subscription(topic: "Test Topic", range: 20, duration: 100, selector: "test = 'true'")
  7. Matchmore.createSubscriptionForMainDevice(subscription: subscription, completion: { _ in
  8. print("🏔 Created Sub")
  9. })
  10. }

Define an object that’s AlpsManagerDelegate implementing OnMatchClojure.

  1. class ExampleMatchHandler: MatchDelegate {
  2. var onMatch: OnMatchClosure?
  3. init(_ onMatch: @escaping OnMatchClosure) {
  4. self.onMatch = onMatch
  5. }
  6. }

Start listening for main device matches changes.

  1. let exampleMatchHandler = ExampleMatchHandler { matches, _ in
  2. print(matches)
  3. }
  4. Matchmore.matchDelegates += exampleMatchHandler

Set up APNS: Certificates for push notifications

Matchmore iOS SDK uses Apple Push Notification Service (APNS) to deliver notifications to your iOS users.

If you already know how to enable APNS, don’t forget to upload the certificate in our portal.

Also, you need to add the following lines to your project AppDelegate.

These callbacks allow the SDK to get the device token.

  1. // Called when APNS has assigned the device a unique token
  2. func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
  3. // Convert token to string
  4. let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)})
  5. Matchmore.registerDeviceToken(deviceToken: deviceTokenString)
  6. }
  7. // Called when APNS failed to register the device for push notifications
  8. func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
  9. Matchmore.processPushNotification(pushNotification: userInfo)
  10. }

Else, you can find help on how to setup APNS.

Example

In MatchmoreExample/ you will find working simple example.

For more complex solution please check Ticketing App:

Documentation

See the http://matchmore.io/documentation/api or consult our website for further information http://matchmore.io/

Authors

License

Matchmore is available under the MIT license. See the LICENSE file for more info.