测试测试 | ✗ |
语言语言 | Obj-CObjective C |
许可 | 自定义 |
发布最后发布 | 2017年11月 |
SwiftSwift 版本 | 3.2 |
由 Gramercy 维护。
依赖 | |
FBSDKCoreKit | = 4.26 |
FBSDKShareKit | = 4.26 |
FBSDKMessengerShareKit | = 1.3.2 |
Branch | = 0.18.8 |
Alamofire | = 4.5 |
Kingfisher | = 4.3.1 |
Locksmith | = 3.0.0 |
SwiftyJSON | = 4.0.0-alpha.1 |
ReachabilitySwift | = 3 |
SwiftHEXColors | = 1.1.0 |
CocoaPods 是 Cocoa 项目的依赖管理器。您可以使用以下命令安装它
$ gem install cocoapods
要使用 Cocoapods 将 GramercySDK 集成到您的 Xcode 项目中,指定它在您的 Podfile
中的目标
platform :ios, '9.0'
target 'testapp' do
use_frameworks!
pod 'GramercySDK', '1.0.15'
end
然后,运行以下命令
$ pod install
安装完任何东西后,您应该打开 {Project}.xcworkspace
而不是 {Project}.xcodeproj
。
.plist
文件,并选择 打开为 -> 源代码。</dict>
元素之前。<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb{{ YOUR FACEBOOK APP ID }}</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>{{ YOUR FACEBOOK APP ID }}</string>
<key>FacebookDisplayName</key>
<string>{{ YOUR APP NAME }}</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fb-messenger</string>
<string>whatsapp</string>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
使用以下方法导入 SDK
import GramercySDK
@import GramercySDK;
导入后,将以下内容添加到您的 AppDelegate.swift
中
let gramercyCampaign:String = "YOUR_CAMPAIGN_ID"
let gramercyKey:String = "YOUR_API_KEY"
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Gramercy.start(withLaunchOptions: launchOptions,
key: gramercyKey,
campaign: gramercyCampaign) { (success, error) in
// do something after a user is attributed a referral
}
return true
}
NSString *key = @"YOUR_CAMPAIGN_ID";
NSString *campaign = @"YOUR_API_KEY";
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[Gramercy startWithLaunchOptions:launchOptions
key:key
campaign:campaign
callback:^(BOOL success, NSError * _Nullable error) {
// do something after a user is attributed a referral
}];
return YES;
}
初始化和启动 SDK 后,您可以为推荐归因识别您的用户。我们建议您何时以及在什么情况下调用 identify 如下
let visitor: GRVisitor = GRVisitor(id:"REFERRED_USER_ID")
visitor.email = "[email protected]"
visitor.firstName = "John"
visitor.lastName = "Doe"
visitor.phone = "17778889999"
Gramercy.identifyVisitor(visitor:visitor) { (success, error) in
// do something after the user is identified
}
识别您的用户后,您可以从任何其他视图中实例化和显示推荐视图控制器
Gramercy.presentReferralsViewController()
// 或者
let controller = Gramercy.instantiateReferralsViewController()
self.present(controller!, animated: true, completion: nil)
[Gramercy presentReferralsViewController];
或者
ReferralsViewController *viewController = [Gramercy instantiateReferralsViewController];
[self showViewController:viewController sender:self];