Matchmore 0.7.3

Matchmore 0.7.3

Maciej Burda维护。



 
依赖
Starscream~> 3.0
Alamofire~> 4.0
 

Matchmore 0.7.3

  • Matchmore SDK团队

Matchmore iOS SDK

Matchmore是一个上下文化的发布/订阅模型,可用于模拟任何基于地理位置或接近度的移动应用程序。通过使用我们的SDK,您可以节省时间并更轻松地进行开发。我们基于Apple Core Location技术构建,同时也提供iBeacon兼容性。

版本控制

SDK是用Swift 4.1编写的。

Matchmore SDK需要iOS 9及以上。

安装

Matchmore可以通过CocoaPods获取,只需将以下行添加到您的Podfile中

pod 'Matchmore'

如果在cocoapods中出现问题,请尝试

pod repo update

使用

有关本示例的完整说明,请参阅文档“教程”

设置应用程序API密钥和世界,可从http://matchmore.io/免费获取。

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

创建第一个设备,发布和订阅。请注意,我们现在不关心错误。

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

定义一个实现OnMatchClojureAlpsManagerDelegate对象。

class ExampleMatchHandler: MatchDelegate {
    var onMatch: OnMatchClosure?
    init(_ onMatch: @escaping OnMatchClosure) {
        self.onMatch = onMatch
    }
}

开始监听主设备匹配的变化。

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

设置APNS:推送通知证书

Matchmore iOS SDK使用Apple推送通知服务(APNS)向您的iOS用户发送通知。

如果您已经知道如何启用APNS,请不要忘记在我们的门户上上传证书。

此外,您还需要将以下行添加到您的项目AppDelegate中。

这些回调允许SDK获取设备令牌。

// Called when APNS has assigned the device a unique token
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    // Convert token to string
    let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)})
    Matchmore.registerDeviceToken(deviceToken: deviceTokenString)
}

// Called when APNS failed to register the device for push notifications
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
    Matchmore.processPushNotification(pushNotification: userInfo)
}

否则,您可以在如何设置APNS的相关帮助中找到。

示例

MatchmoreExample/中,您可以找到可工作的简单示例。

对于更复杂的解决方案,请查看票务应用程序

文档

请参阅http://matchmore.io/documentation/api或访问我们的网站获取更多信息http://matchmore.io/

作者

许可证

Matchmore可用MIT许可证。有关更多信息,请参阅LICENSE文件。