i need for the pushwoosh sdk still AppDelegate... in the appdelegate - how can i access the webview and change the url (depending on push notifications received from appdelegate? pushnotifications and everything works... also the initial webpage is loaded on startup. but how can i change url within the app delegate?
MAIN APP:
@main
struct XYApp: App {
@UIApplicationDelegateAdaptor var delegate: FSAppDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
class FSAppDelegate: UIResponder, UIApplicationDelegate, PWMessagingDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
//initialization code
//set custom delegate for push handling, in our case AppDelegate
Pushwoosh.sharedInstance()?.delegate = self;
//register for push notifications
Pushwoosh.sharedInstance()?.registerForPushNotifications()
print("token: ",Pushwoosh.sharedInstance()?.getPushToken())
return true
}
}
contenview swift
import SwiftUI
struct ContentView: View {
@State private var showWebView = false
var body: some View {
WebView(url: URL(string: "https://www.xy.com/mobile")!)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
webview swift
import SwiftUI
import WebKit
struct WebView: UIViewRepresentable {
var url: URL
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
func updateUIView(_ webView: WKWebView, context: Context) {
let request = URLRequest(url: url)
webView.load(request)
}
}