@@ -24,6 +24,7 @@ import Language.Javascript.JSaddle.WKWebView.Internal
2424 (jsaddleMain, jsaddleMainHTMLWithBaseURL, jsaddleMainFile, WKWebView(..), mainBundleResourcePath)
2525import System.Environment (getProgName)
2626import Foreign.C.String (CString, withCString)
27+import Foreign.C.Types (CBool)
2728import Foreign.StablePtr (StablePtr, newStablePtr)
2829import Language.Javascript.JSaddle (JSM)
2930
@@ -47,7 +48,8 @@ foreign import ccall runInWKWebView
4748 -> Word64 -- registerForRemoteNotifications
4849 -> StablePtr (CString -> IO ()) -- didRegisterForRemoteNotificationsWithDeviceToken
4950 -> StablePtr (CString -> IO ()) -- didFailToRegisterForRemoteNotificationsWithError
50− -> Word64 -- Allow developer tools
51+ -> Word64 -- developerExtrasEnabled
52+ -> StablePtr (CString -> IO CBool) -- applicationOpenFile
5153 -> IO ()
5254
5355data AppDelegateConfig = AppDelegateConfig
@@ -60,8 +62,20 @@ data AppDelegateConfig = AppDelegateConfig
6062 , _appDelegateConfig_applicationWillTerminate :: IO ()
6163 , _appDelegateConfig_applicationSignificantTimeChange :: IO ()
6264 , _appDelegateConfig_applicationUniversalLink :: CString -> IO ()
65+ -- ^ Called when the app is launched from a URL. 'CString' contains the URL.
66+ --
67+ -- The Core Foundation plist key CFBundleURLTypes controls which URL schemes
68+ -- the app should respond to.
6369 , _appDelegateConfig_appDelegateNotificationConfig :: AppDelegateNotificationConfig
6470 , _appDelegateConfig_developerExtrasEnabled :: Bool
71+ -- ^ Allow devtools in the app. Defaults to 'True'
72+ , _appDelegateConfig_applicationOpenFile :: CString -> IO Bool
73+ -- ^ Called when the app is launched by opening a file. 'CString' contains
74+ -- the file path. Return value is 'True' if the file was successfully
75+ -- opened. Defaults to ignoring the file and returning 'False'.
76+ --
77+ -- The Core Foundation plist key CFBundleDocumentTypes controls which file
78+ -- types should be associated with the app.
6579 }
6680
6781instance Default AppDelegateConfig where
@@ -77,6 +91,7 @@ instance Default AppDelegateConfig where
7791 , _appDelegateConfig_applicationUniversalLink = \_ -> return ()
7892 , _appDelegateConfig_appDelegateNotificationConfig = def
7993 , _appDelegateConfig_developerExtrasEnabled = True
94+ , _appDelegateConfig_applicationOpenFile = \_ -> return False
8095 }
8196
8297data AuthorizationOption = AuthorizationOption_Badge
@@ -147,6 +162,7 @@ run' cfg main = do
147162 applicationWillTerminate <- newStablePtr $ _appDelegateConfig_applicationWillTerminate cfg
148163 applicationSignificantTimeChange <- newStablePtr $ _appDelegateConfig_applicationSignificantTimeChange cfg
149164 applicationUniversalLink <- newStablePtr $ _appDelegateConfig_applicationUniversalLink cfg
165+ applicationOpenFile <- newStablePtr $ fmap fromBool . _appDelegateConfig_applicationOpenFile cfg
150166
151167 -- AppDelegate notification configuration
152168 let ncfg = _appDelegateConfig_appDelegateNotificationConfig cfg
@@ -178,3 +194,4 @@ run' cfg main = do
178194 didRegisterForRemoteNotificationsWithDeviceToken
179195 didFailToRegisterForRemoteNotificationsWithError
180196 (fromBool $ _appDelegateConfig_developerExtrasEnabled cfg)
197+ applicationOpenFile