5

I'm handling the lunchUrl in my original webview but the problem is when I put kOSSettingsKeyInAppLaunchURL

[true] it opens new webview over my original webview

[false] it opens the link in safary

let notificationOpenedBlock: OSHandleNotificationActionBlock = { result in
    let payload = result?.notification.payload
    if let additionalData = result!.notification.payload!.additionalData {
        // DEEP LINK and open url in RedViewController
        centerViewController.receivedURL = payload!.launchURL as! String!

        self.window = UIWindow(frame: UIScreen.main.bounds)
        self.window?.rootViewController = centerViewController
        self.window?.makeKeyAndVisible()
    }
}

OneSignal.initWithLaunchOptions(launchOptions, appId: "*****", handleNotificationReceived: { (notification) in
    }, handleNotificationAction: notificationOpenedBlock , settings: [kOSSettingsKeyAutoPrompt : true, kOSSettingsKeyInFocusDisplayOption : OSNotificationDisplayType.notification.rawValue, kOSSettingsKeyInAppLaunchURL: true])
Arasuvel
  • 2,971
  • 1
  • 25
  • 40
Tarek
  • 51
  • 3

1 Answers1

0

Try to use this code in Appdelegate,:

let notificationOpenedBlock: OSHandleNotificationActionBlock = { result in
    // This block gets called when the user reacts to a notification received
    let payload: OSNotificationPayload = result!.notification.payload

    /// Check response message click notification in here
    var fullMessage = payload.body
    self.window?.rootViewController = UINavigationController(rootViewController: ViewController())

    }

    if payload.additionalData != nil {
        if payload.title != nil {
            let messageTitle = payload.title
            let additional = payload.additionalData["recive_id"] as! String
            print("tes aditional data: \(additional)")
            print("Message Title = \(messageTitle!)") //proses notif klik "3" Goto target
            if messageTitle == "id" {
                self.window?.rootViewController = UINavigationController(rootViewController: ViewController())
            }
        }

        let additionalData = payload.additionalData
        if additionalData?["actionSelected"] != nil {
            fullMessage = fullMessage! + "\nPressed ButtonID: \(String(describing: additionalData!["actionSelected"]))"
        }
    }
}
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Jeri P.M
  • 399
  • 5
  • 15