WeLoop 2.1.0

WeLoop 2.1.0

HHK 维护。



WeLoop 2.1.0

  • WeLoop

Version Platform

示例

要运行示例项目,请克隆仓库,然后从 Example 目录中首先运行 pod install

在 AppDelegate.swift 中,用您自己的更新模拟 projectGUID

要求

由于 WeLoop 在 swift 5.0 中构建,因此需要 Xcode 10.2 才能构建项目。

依赖项需要 iOS 9.0 或更高版本才能构建。

安装

WeLoop 通过 CocoaPods 提供。要安装它,请简单地添加以下行到您的 Podfile

pod 'WeLoop'

使用

与场景委托的兼容性

如果您的应用程序使用 UISceneSession,您需要在应用程序代理中早期配置 SDK。

WeLoop.set(sceneBasedApplication: true)

在下一个大版本中,这将不再必要。

调用

为了调用WeLoop,您有两种选择。

  1. 您提供用户身份。只需提供您的项目密钥,并通过调用identifyUser来识别当前用户。
WeLoop.initialize(apiKey: "YOUR_PROJECT_GUID");
let user = User(id: "1", email: "[email protected]", firstName: "test1", lastName: "test2")
WeLoop.authenticateUser(user: user)
  1. 您让用户自行提供登录信息:不要调用`authenticateUser`,当小部件启动时,它将显示登录页面。
WeLoop.initialize(apiKey: "YOUR_PROJECT_GUID");

调用方法

您可以选择以下不同方法在您的应用程序中调用WeLoop小部件:

  1. 浮动操作按钮
WeLoop.set(invocationMethod: .fab)

按钮的自定义选项(颜色、图标、位置)可以在您的WeLoop项目设置中进行。

  1. 摇晃手势
WeLoop.set(invocationMethod: .shakeGesture)
  1. 手动
WeLoop.set(invocationMethod: .manual)

// Then, in your own button or control:

WeLoop.invoke()

委托方法

您可以使用以下方法设置委托以监听SDK返回的一些事件:WeLoop.set(delegate: self)

然后您可以实现以下可选的委托方法

extension AppDelegate: WeLoopDelegate {
    
    func initializationSuccessful() {
        // From this point forward, we can safely invoke the Widget manually
    }
    
    func initializationFailed(with error: Error) {
        // Initialization Failed (no network for example). Based on the error you'll have to retry the initialization later.
        print(error)
    }
    
    func failedToLaunch(with error: Error) {
        // The widget could not be launched. Most likely is that the initialization process failed, or the user is missing in autoAuthentication
        print(error)
    }
    
    func notificationCountUpdated(newCount: Int) {
        // Set the new count on your custom view
        print(newCount)
    }
}

更新您的plist文件

由于WeLoop提供了从用户相册和相机上传照片的可能性,如果您还没有做,您必须将以下条目添加到您的plist文件中:

<key>NSPhotoLibraryUsageDescription</key>
<string>WeLoop needs to access your library to share pictures from your library</string>
<key>NSCameraUsageDescription</key>
<string>WeLoop needs to access your camera to take pictures</string>

许可协议

WeLoop遵循MIT许可协议。有关更多信息,请参阅LICENSE文件。