Last active
April 24, 2024 20:22
-
-
Save iAmWillShepherd/5522fb3efc67983160e244818c6e6b38 to your computer and use it in GitHub Desktop.
Snippet showing OneSignal User Model SDK initialization in Swift for Apple devices.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import DotEnv | |
import OneSignalFramework | |
@main | |
struct MyApp: App { | |
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate | |
var body: some Scene { | |
WindowGroup { | |
ContentView() | |
} | |
} | |
} | |
class AppDelegate: UIResponder, UIApplicationDelegate, OSInAppMessageLifecycleListener { | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { | |
let env = DotEnv(withFile: ".env") | |
env.load() | |
OneSignal.initialize(env.get("ONESIGNAL_APP_ID"), withLaunchOptions: launchOptions) | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment