Skip to content
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
E698B7492C626B0600084371 /* RadarSDKMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E698B7412C626AE600084371 /* RadarSDKMotion.framework */; };
E698B7502C627A1600084371 /* RadarSDKMotion.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E698B7412C626AE600084371 /* RadarSDKMotion.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
F625D7F92C3337650024D1E7 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F625D7F82C3337650024D1E7 /* Launch Screen.storyboard */; };
F6513F602E6B736200523472 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6513F5F2E6B736200523472 /* MainView.swift */; };
F66DAD6A2E707F0700896773 /* waypoints.gpx in Sources */ = {isa = PBXBuildFile; fileRef = F66DAD642E707F0300896773 /* waypoints.gpx */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -76,6 +78,8 @@
E632FA1C2CAC366C00E86C85 /* Example.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Example.entitlements; sourceTree = "<group>"; };
E698B7382C626AE600084371 /* RadarSDKMotion.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RadarSDKMotion.xcodeproj; path = ../../RadarSDKMotion/RadarSDKMotion.xcodeproj; sourceTree = "<group>"; };
F625D7F82C3337650024D1E7 /* Launch Screen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = "<group>"; };
F6513F5F2E6B736200523472 /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
F66DAD642E707F0300896773 /* waypoints.gpx */ = {isa = PBXFileReference; lastKnownFileType = text; path = waypoints.gpx; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -116,6 +120,8 @@
DD236D34230A006900EB88F9 /* Info.plist */,
DDB861D22385FC3E00770661 /* [email protected] */,
DD236D26230A006700EB88F9 /* AppDelegate.swift */,
F6513F5F2E6B736200523472 /* MainView.swift */,
F66DAD642E707F0300896773 /* waypoints.gpx */,
DD291168230D0AF900049D3A /* Utils.swift */,
DD236D2F230A006900EB88F9 /* Assets.xcassets */,
DD86FCF9239185F4003225F6 /* RadarSDK.xcodeproj */,
Expand Down Expand Up @@ -267,7 +273,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F66DAD6A2E707F0700896773 /* waypoints.gpx in Sources */,
DD236D27230A006700EB88F9 /* AppDelegate.swift in Sources */,
F6513F602E6B736200523472 /* MainView.swift in Sources */,
DD291169230D0AF900049D3A /* Utils.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
39 changes: 20 additions & 19 deletions Example/Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import UIKit
import UserNotifications
import RadarSDK
import SwiftUI


@UIApplicationMain
Expand All @@ -18,6 +19,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIWindowSceneDelegate, UN

var scrollView: UIScrollView?
var demoFunctions = Array<() -> Void>()

var useSwiftUI = true

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { (_, _) in }
Expand All @@ -28,10 +31,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIWindowSceneDelegate, UN

// Replace with a valid test publishable key
let radarInitializeOptions = RadarInitializeOptions()

UserDefaults.standard.set("https://api.radar-staging.com", forKey: "radar-host")
// Uncomment to enable automatic setup for notification conversions or deep linking
//radarInitializeOptions.autoLogNotificationConversions = true
//radarInitializeOptions.autoHandleNotificationDeepLinks = true
Radar.initialize(publishableKey: "prj_test_pk_0000000000000000000000000000000000000000", options: radarInitializeOptions )
Radar.initialize(publishableKey: "prj_test_pk_", options: radarInitializeOptions )
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The publishable key appears to be incomplete or a placeholder. Ensure this is not accidentally committed to version control with a real key.

Copilot uses AI. Check for mistakes.
Radar.setUserId("testUserId")
Radar.setMetadata([ "foo": "bar" ])
Radar.setDelegate(self)
Expand Down Expand Up @@ -75,12 +80,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIWindowSceneDelegate, UN
let window = UIWindow(windowScene: windowScene)

window.backgroundColor = .white

scrollView = UIScrollView(frame: CGRect(x: 0, y: 100, width: window.frame.size.width, height: window.frame.size.height))
scrollView!.contentSize.height = 0
scrollView!.contentSize.width = window.frame.size.width

window.addSubview(scrollView!)

if (useSwiftUI) {
let controller = UIHostingController(rootView: MainView())
controller.view.frame = UIScreen.main.bounds
window.addSubview(controller.view)
} else {
scrollView = UIScrollView(frame: CGRect(x: 0, y: 100, width: window.frame.size.width, height: window.frame.size.height))
scrollView!.contentSize.height = 0
scrollView!.contentSize.width = window.frame.size.width

window.addSubview(scrollView!)
}

window.makeKeyAndVisible()

Expand All @@ -96,7 +107,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIWindowSceneDelegate, UN
}
}


demoButton(text: "iam") {
Radar.showInAppMessage(RadarInAppMessage.fromDictionary([
"title": [
Expand Down Expand Up @@ -430,27 +440,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIWindowSceneDelegate, UN
}

func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
print("will present notification!")
completionHandler([.list, .banner, .sound])
}

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
// Uncomment for manual setup for notification conversions and URLs
// Radar.logConversion(response: response)
// Radar.openURLFromNotification(response.notification)
print("Received notification!")
}

func notify(_ body: String) {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { (granted, error) in
if granted {
let content = UNMutableNotificationContent()
content.body = body
content.sound = UNNotificationSound.default
content.categoryIdentifier = "example"

let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: nil)
UNUserNotificationCenter.current().add(request, withCompletionHandler: { (_) in })
}
}
}

func didReceiveEvents(_ events: [RadarEvent], user: RadarUser?) {
Expand Down
Loading