Skip to content

Instantly share code, notes, and snippets.

@monkeywithacupcake
Created November 11, 2017 08:23
Show Gist options
  • Save monkeywithacupcake/4b0d19ea2bc4c0c910befa06d430b814 to your computer and use it in GitHub Desktop.
Save monkeywithacupcake/4b0d19ea2bc4c0c910befa06d430b814 to your computer and use it in GitHub Desktop.
Parts of files for testing branch
//
// AppDelegate.swift
//
import UIKit
import CoreData
import Firebase
import TwitterKit
import FBSDKCoreKit
import Branch
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Firebase
// need this for Firebase Dynamic links
//FirebaseOptions.defaultOptions()?.deepLinkURLScheme = self.customURLScheme
// all firebase app need this
FirebaseApp.configure()
// Branch for links
let branch: Branch = Branch.getInstance()
branch.initSession(launchOptions: launchOptions, andRegisterDeepLinkHandler: {params, error in
if error == nil {
// params are the deep linked params associated with the link that the user clicked -> was re-directed to this app
// params will be empty if no data found
// ... insert custom logic here ...
print("params: %@", params as? [String: AnyObject] ?? {})
}
})
// Twitter
Twitter.sharedInstance().start(
withConsumerKey:AppData.twitterConsumerKey,
consumerSecret:AppData.twitterConsumerSecret)
// Facebook
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}
// Respond to URI scheme links
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
// pass the url to the handle deep link call
let branchHandled = Branch.getInstance().application(application,
open: url,
sourceApplication: sourceApplication,
annotation: annotation
)
if (!branchHandled) {
// If not handled by Branch, do other deep link routing for the Facebook SDK, Pinterest SDK, etc
}
// do other deep link routing for the Facebook SDK, Pinterest SDK, etc
if url.scheme != nil && url.scheme == AppData.facebookID{
// signing in with facebook
return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
}
else{
return Twitter.sharedInstance().application(application, open:url, options: [:])
}
return true
}
// Respond to Universal Links
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
// pass the url to the handle deep link call
Branch.getInstance().continue(userActivity)
return true
}
}
2017-11-11 08:34:41.550915+0900 travel2[9900:2567690] [Firebase/Analytics][I-ACS023007] Firebase Analytics v.40004000 started
2017-11-11 08:34:41.566490+0900 travel2[9900:2567690] [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2017-11-11 08:34:41.700441+0900 travel2[9900:2567697] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-11-11 08:34:41.703213+0900 travel2[9900:2567697] [MC] Reading from public effective user settings.
2017-11-11 08:34:41.938207+0900 travel2[9900:2567581] <CATransformLayer: 0x1c02249e0> - changing property contentsGravity in transform-only layer, will have no effect
92OArBhi8Qe7kR7d0sMKlrbyd9l2
2017-11-11 08:34:42.080910+0900 travel2[9900:2567581] VC trying to retrieveProfile
2017-11-11 08:34:42.080966+0900 travel2[9900:2567581] ProfileModel trying to retrieveProfile
2017-11-11 08:34:42.081000+0900 travel2[9900:2567581] FBM trying to retrieveProfile
2017-11-11 08:34:42.089638+0900 travel2[9900:2567581] refreshPreferences: HangTracerEnabled: 0
2017-11-11 08:34:42.089720+0900 travel2[9900:2567581] refreshPreferences: HangTracerDuration: 500
2017-11-11 08:34:42.089753+0900 travel2[9900:2567581] refreshPreferences: ActivationLoggingEnabled: 0 ActivationLoggingTaskedOffByDA:0
2017-11-11 08:34:43.160095+0900 travel2[9900:2567682] [BoringSSL] Function boringssl_context_get_peer_sct_list: line 1754 received sct extension length is less than sct data length
2017-11-11 08:34:43.520919+0900 travel2[9900:2567701] [BoringSSL] Function boringssl_context_get_peer_sct_list: line 1754 received sct extension length is less than sct data length
params: %@ ["+clicked_branch_link": 0, "+is_first_session": 0, "+non_branch_link": com.majikprod.travel2://google/link/?dismiss=1&is_weak_match=1]
2017-11-11 08:34:43.962948+0900 travel2[9900:2567682] TIC Read Status [1:0x0]: 1:57
2017-11-11 08:34:43.963160+0900 travel2[9900:2567682] TIC Read Status [1:0x0]: 1:57
2017-11-11 08:34:44.182670+0900 travel2[9900:2567581] [MC] Lazy loading NSBundle MobileCoreServices.framework
2017-11-11 08:34:44.185902+0900 travel2[9900:2567581] [MC] Loaded MobileCoreServices.framework
2017-11-11 08:34:44.574444+0900 travel2[9900:2567690] TIC Read Status [5:0x0]: 1:57
2017-11-11 08:34:44.574503+0900 travel2[9900:2567690] TIC Read Status [5:0x0]: 1:57
2017-11-11 08:34:44.625180+0900 travel2[9900:2567681] TIC Read Status [6:0x0]: 1:57
2017-11-11 08:34:44.625318+0900 travel2[9900:2567681] TIC Read Status [6:0x0]: 1:57
2017-11-11 08:34:45.463599+0900 travel2[9900:2567690] TIC TCP Conn Failed [7:0x1c4174dc0]: 12:8 Err(-65554)
2017-11-11 08:34:45.466377+0900 travel2[9900:2567696] Task <AA135DE4-5E9F-4E2D-99EC-E23C83845D00>.<3> HTTP load failed (error code: -1003 [12:8])
2017-11-11 08:34:45.467264+0900 travel2[9900:2567696] Task <AA135DE4-5E9F-4E2D-99EC-E23C83845D00>.<3> finished with error - code: -1003
2017-11-11 08:34:47.646699+0900 travel2[9900:2567696] TIC Read Status [2:0x0]: 1:57
2017-11-11 08:34:47.646833+0900 travel2[9900:2567696] TIC Read Status [2:0x0]: 1:57
2017-11-11 08:34:47.647420+0900 travel2[9900:2567696] TIC Read Status [8:0x0]: 1:57
2017-11-11 08:34:47.647647+0900 travel2[9900:2567696] TIC Read Status [8:0x0]: 1:57
2017-11-11 08:34:47.648043+0900 travel2[9900:2567696] TIC Read Status [3:0x0]: 1:57
2017-11-11 08:34:47.648118+0900 travel2[9900:2567696] TIC Read Status [3:0x0]: 1:57
warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.
Error: Unable to capture view hierarchy.
Details: Log Title: Data source expression execution failure.
Log Details: error evaluating expression “(id)[[(Class)objc_getClass("DBGTargetHub") sharedHub] performRequestWithRequestInBase64:@"YnBsaXN0MDDUAQIDBAUGRkdYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3ASAAGGoK8QFwcIGxwdHh8gISIuLzAxMjM0Nz1BQkNEVSRudWxs0wkKCwwTGldOUy5rZXlzWk5TLm9iamVjdHNWJGNsYXNzpg0ODxAREoACgAOABIAFgAaAB6YUFRYXGBmACIAJgBOAD4AUgBWAFl8QG0RCR0hpZXJhcmNoeVJlcXVlc3RQcmlvcml0eV8QHERCR0hpZXJhcmNoeVJlcXVlc3RQcmVkaWNhdGVfEBdEQkdIaWVyYXJjaHlSZXF1ZXN0TmFtZV8QHkRCR0hpZXJhcmNoeVJlcXVlc3RTcGluUnVubG9vcF8QHURCR0hpZXJhcmNoeVJlcXVlc3RJZGVudGlmaWVyXxAXREJHSGllcmFyY2h5UmVxdWVzdFR5cGUQANMJCgsjKC2kJCUmJ4AKgAuADIANpCkXKyuADoAPgBCAEIASXxATc3RyaWN0ZXN0VmlzaWJpbGl0eV8QEWluY2x1ZGVMYXp5VmFsdWVzXxATZW51bVByb3ZpZGVyQ2xhc3Nlc18QFm9wdGlvbnNQcm92aWRlckNsYXNzZXMQAwjSCgs1NqCAEdI4OTo7WiRjbGFzc25hbWVYJGNsYXNzZXNXTlNBcnJheaI6PFhOU09iamVjdNI4OT4/XxATTlNNdXRhYmxlRGljdGlvbmFyeaM+QDxcTlNEaWN0aW9uYXJ5XxAPSW5pdGlhbCByZXF1ZXN0XxAkRDE2NERDMTctNUIxNS00NEQ3LTg1Q0QtQzI1QjEyRUNDNDBDEAHSODlARaJAPF8QD05TS2V5ZWRBcmNoaXZlctFISVRyb290gAEACAARABoAIwAtADIANwBRAFcAXgBmAHEAeAB/AIEAgwCFAIcAiQCLAJIAlACWAJgAmgCcAJ4AoAC+AN0A9wEYATgBUgFUAVsBYAFiAWQBZgFoAW0BbwFxAXMBdQF3AY0BoQG3AdAB0gHTAdgB2QHbAeAB6wH0AfwB/wIIAg0CIwInAjQCRgJtAm8CdAJ3AokCjAKRAAAAAAAAAgEAAAAAAAAASgAAAAAAAAAAAAAAAAAAApM="]”: error: Couldn't materialize: couldn't allocate a temporary region for the result: failed to send packet: 'M105cc8d20,8:0000000000000000'
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
Missing: libViewDebuggerSupport, DebugHierarchyFoundation
Log Method: -[DBGDataSourceConnectionLibViewDebugger _executeLLDBExpression:forRequest:onPotentialThread:iteration:]_block_invoke_2
Method: -[DBGViewDebugger updateDebugHierarchy]_block_invoke_2
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
(lldb)
//
// FakeSettingsViewController.swift
//
import UIKit
import Branch
class SettingsViewController: UIViewController {
// MARK: - Properties
@IBOutlet weak var linkLabel: UILabel!
var theTestLink: String?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func goBackTapped(_ sender: UIButton) {
self.presentingViewController?.dismiss(animated: true, completion: nil)
}
@IBAction func linkTestTapped(_ sender: UIButton) {
createLink()
}
func createLink() {
// associate data with a link
// you can access this data from any instance that installs or opens the app from this link (amazing...)
var params = ["user": "Joe"]
params["profile_pic"] = "https://s3-us-west-1.amazonaws.com/myapp/joes_pic.jpg"
params["description"] = "Joe likes long walks on the beach..."
// Customize the display of the link
params["$og_title"] = "Joe's My App Referral"
params["$og_image_url"] = "https://s3-us-west-1.amazonaws.com/myapp/joes_pic.jpg"
params["$og_description"] = "Join Joe in My App - it's awesome"
// Customize the redirect performance
params["$desktop_url"] = "http://myapp.com/desktop_splash"
// associate a url with a set of tags, channel, feature, and stage for better analytics.
// tags: nil or example set of tags could be "version1", "trial6", etc; each tag should not exceed 64 characters
// channel: nil or examples: "facebook", "twitter", "text_message", etc; should not exceed 128 characters
// feature: nil or examples: FEATURE_TAG_SHARE, FEATURE_TAG_REFERRAL, "unlock", etc; should not exceed 128 characters
// stage: nil or examples: "past_customer", "logged_in", "level_6"; should not exceed 128 characters
// Link 'type' can be used for scenarios where you want the link to only deep link the first time.
// Use nil, BranchLinkTypeUnlimitedUse or BranchLinkTypeOneTimeUse
// Link 'alias' can be used to label the endpoint on the link. For example: http://bnc.lt/AUSTIN28. Should not exceed 128 characters
// Be careful about aliases: these are immutable objects permanently associated with the data and associated paramters you pass into the link. When you create one in the SDK, it's tied to that user identity as well (automatically specified by the Branch internals). If you want to retrieve the same link again, you'll need to call getShortUrl with all of the same parameters from before.
// The callback will return null if the link generation fails (or if the alias specified is aleady taken.)
Branch.getInstance().getShortURL(withParams: params, andTags: ["version1", "trial6"], andChannel: "text_message", andFeature: BRANCH_FEATURE_TAG_SHARE, andStage: "level_6", andCallback: { (url: String!, error: NSError!) -> Void in
if (error == nil) {
print(url)
self.theTestLink = url
// show the link to the user or share it immediately
self.linkLabel.text = url
} // something happened
print(error)
} as! callbackWithUrl)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment