こちらのライブラリを使って、カスタムURLを開いて画面遷移をしています。
iOSアプリの大規模なCustom URL Schemeを支える技術
このライブラリをNotificationを開いたときに、含まれているURLにも適用させたいです。
swift
1 2import Crossroad 3let router: DefaultRouter = { 4 let router = DefaultRouter(scheme: "appname") 5 router.register([ 6 ("appname://main/:token", { context in 7 // 画面をひらく処理 8 return true 9 }) 10 ]) 11 return router 12 }() 13 14// カスタムURLからひらく 15func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any]) -> Bool { 16 // こう使ってる 17 return router.openIfPossible(url, options: options) 18 }
これをuserNotificationCenter内でも使いたいです。
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { let userInfo = response.notification.request.content.userInfo let aps = userInfo["aps"] as? [AnyHashable: Any] let url = NSURL(string: (aps?["url"] as? String)!) // こう使いたいがoptionsの設定の仕方がわからない router.openIfPossible(url, options: options) completionHandler() }
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/10/11 08:36