Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
xtai committed May 2, 2023
0 parents commit 6a060da
Show file tree
Hide file tree
Showing 32 changed files with 1,234 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Sean Tai

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SDK Playground

<img src="./assets/app-icon.png" width="128" alt="The App icon of the SDK Playground iOS app. The icon includes a blue playground slide on a white background.">

A demo iOS app to test Facebook SDK integration for app events and deep links.

- Send standard and custom app events
- Test automatic advanced matching
- Test deep link

<img src="./assets/screenshots.png" width="1024" alt="Screenshot of the SDK Playground app and its features.">

<img src="./assets/devices.png" width="600" alt="Screenshots of the SDK Playground app running on iPad and iPhones.">
440 changes: 440 additions & 0 deletions SDK Playground.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Sean Playground.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>SDK Playground.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>Sean Playground.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
18 changes: 18 additions & 0 deletions SDK Playground/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// AppDelegate.swift
// SDK Playground
//
// Created by Sean Tai on 5/1/23.
//

import SwiftUI

class AppDelegate: NSObject, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
// AppDelegate didFinishLaunchingWithOptions
return true
}
}
11 changes: 11 additions & 0 deletions SDK Playground/Assets.xcassets/AccentColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
14 changes: 14 additions & 0 deletions SDK Playground/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"images" : [
{
"filename" : "sdk-playground.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions SDK Playground/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
32 changes: 32 additions & 0 deletions SDK Playground/ContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// ContentView.swift
// SDK Playground
//
// Created by Sean Tai on 5/1/23.
//

import SwiftUI

struct ContentView: View {
@EnvironmentObject private var appData: AppData

var body: some View {
TabView(selection: $appData.activeTab) {
SendEvents().tag(Tab.sendEvents).tabItem {
Label(Tab.sendEvents.label, systemImage: Tab.sendEvents.symbolImage)
}
DeepLink().tag(Tab.deepLink).tabItem {
Label(Tab.deepLink.label, systemImage: Tab.deepLink.symbolImage)
}
About().tag(Tab.about).tabItem {
Label(Tab.about.label, systemImage: Tab.about.symbolImage)
}
}
}
}

struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView().environmentObject(AppData())
}
}
72 changes: 72 additions & 0 deletions SDK Playground/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Playground</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>1.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>sdkpark</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>sdkpg</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict/>
</dict>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchScreen</key>
<dict>
<key>UILaunchScreen</key>
<dict/>
</dict>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~iphone</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
14 changes: 14 additions & 0 deletions SDK Playground/Model/AppData.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// AppData.swift
// SDK Playground
//
// Created by Sean Tai on 5/1/23.
//

import SwiftUI

class AppData: ObservableObject {
@Published var activeTab: Tab = .sendEvents
@Published var deepLinkContent: String = ""
@State private var showWebView = false
}
53 changes: 53 additions & 0 deletions SDK Playground/Model/ReadInfo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// ReadInfo.swift
// SDK Playground
//
// Created by Sean Tai on 5/1/23.
//

import SwiftUI

extension UIApplication {
static var appVersion: String? {
return Bundle.main.object(forInfoDictionaryKey: "CFBundleInfoDictionaryVersion") as? String
}

static let externalURLSchemes: [String] = {
guard let urlTypes = Bundle.main.infoDictionary?["CFBundleURLTypes"] as? [[String: Any]] else {
return []
}

var result: [String] = []
for urlTypeDictionary in urlTypes {
guard let urlSchemes = urlTypeDictionary["CFBundleURLSchemes"] as? [String] else { continue }
guard let externalURLScheme = urlSchemes.first else { continue }
result.append(externalURLScheme)
}

return result
}()

static var FacebookAppID: String {
(Bundle.main.object(forInfoDictionaryKey: "FacebookAppID") as? String) ?? "Not Found"
}

static var FacebookDisplayName: String {
(Bundle.main.object(forInfoDictionaryKey: "FacebookDisplayName") as? String) ?? "Not Found"
}

static var FacebookAutoLogAppEventsEnabled: String {
if let value = Bundle.main.object(forInfoDictionaryKey: "FacebookAutoLogAppEventsEnabled") as? Bool {
return String(value)
} else {
return "Not Found"
}
}

static var FacebookAdvertiserIDCollectionEnabled: String {
if let value = Bundle.main.object(forInfoDictionaryKey: "FacebookAdvertiserIDCollectionEnabled") as? Bool {
return String(value)
} else {
return "Not Found"
}
}
}
36 changes: 36 additions & 0 deletions SDK Playground/Model/Tab.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Tab.swift
// SDK Playground
//
// Created by Sean Tai on 5/1/23.
//

import SwiftUI

enum Tab: String, CaseIterable {
case sendEvents = "sendEvents"
case deepLink = "deepLink"
case about = "about"

var symbolImage: String {
switch self {
case .sendEvents: return "paperplane.fill"
case .deepLink: return "app.connected.to.app.below.fill"
case .about: return "info.circle.fill"
}
}

var label: String {
switch self {
case .sendEvents: return "Send Events"
case .deepLink: return "Test Deep Link"
case .about: return "About"
}
}

static func convert(from: String) -> Self? {
return Tab.allCases.first { tab in
tab.rawValue.lowercased() == from.lowercased()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
34 changes: 34 additions & 0 deletions SDK Playground/SDKPlaygroundApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// SDKPlaygroundApp.swift
// SDK Playground
//
// Created by Sean Tai on 5/1/23.
//

import SwiftUI

@main
struct SDKPlaygroundApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@StateObject private var appData: AppData = .init()

var body: some Scene {
WindowGroup {
ContentView().environmentObject(appData).onOpenURL { url in
// Deep link URL detected
appData.deepLinkContent = url.absoluteString
print("Deep Link opened: \(url.absoluteString)")

// Open tab via deep link
for component in url.query!.components(separatedBy: "&") {
if component.contains("tab=") {
let tabRawValue = component.replacingOccurrences(of: "tab=", with: "")
if let requestedTab = Tab.convert(from: tabRawValue) {
appData.activeTab = requestedTab
}
}
}
}
}
}
}
Loading

0 comments on commit 6a060da

Please sign in to comment.