@@ -9,7 +9,6 @@ module Language.Javascript.JSaddle.WKWebView
99 , runHTMLWithBaseURL
1010 , runFile
1111 , mainBundleResourcePath
12− , ApplicationState (..)
1312 , AppDelegateConfig (..)
1413 , AppDelegateNotificationConfig (..)
1514 , AuthorizationOption (..)
@@ -25,7 +24,6 @@ import Language.Javascript.JSaddle.WKWebView.Internal
2524 (jsaddleMain, jsaddleMainHTMLWithBaseURL, jsaddleMainFile, WKWebView(..), mainBundleResourcePath)
2625import System.Environment (getProgName)
2726import Foreign.C.String (CString, withCString)
28−import Foreign.C.Types (CBool, CInt)
2927import Foreign.StablePtr (StablePtr, newStablePtr)
3028import Language.Javascript.JSaddle (JSM)
3129
@@ -41,7 +39,6 @@ foreign import ccall runInWKWebView
4139 -> StablePtr (IO ()) -- applicationWillTerminate
4240 -> StablePtr (IO ()) -- applicationSignificantTimeChange
4341 -> StablePtr (CString -> IO ()) -- applicationUniversalLink
44− -> StablePtr (CInt -> CString -> IO ()) -- applicationDidReceiveRemoteNotification
4542 -> Word64 -- whether to run requestAuthorizationWithOptions
4643 -> Word64 -- Ask for Badge authorization
4744 -> Word64 -- Ask for Sound authorization
@@ -50,8 +47,7 @@ foreign import ccall runInWKWebView
5047 -> Word64 -- registerForRemoteNotifications
5148 -> StablePtr (CString -> IO ()) -- didRegisterForRemoteNotificationsWithDeviceToken
5249 -> StablePtr (CString -> IO ()) -- didFailToRegisterForRemoteNotificationsWithError
53− -> Word64 -- developerExtrasEnabled
54− -> StablePtr (CString -> IO CBool) -- applicationOpenFile
50+ -> Word64 -- Allow developer tools
5551 -> IO ()
5652
5753data AppDelegateConfig = AppDelegateConfig
@@ -64,25 +60,8 @@ data AppDelegateConfig = AppDelegateConfig
6460 , _appDelegateConfig_applicationWillTerminate :: IO ()
6561 , _appDelegateConfig_applicationSignificantTimeChange :: IO ()
6662 , _appDelegateConfig_applicationUniversalLink :: CString -> IO ()
67− -- ^ Called when the app is launched from a URL. 'CString' contains the URL.
68− --
69− -- The Core Foundation plist key CFBundleURLTypes controls which URL schemes
70− -- the app should respond to.
71− , _appDelegateConfig_applicationDidReceiveRemoteNotification :: ApplicationState -> CString -> IO ()
72− -- ^ Called when the application receives a remote notification.
73− -- 'ApplicationState' is the current state of the app.
74− -- The 'CString' JSON-encoded user info contained in the notification.
75− -- For more information see https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623117-application?language=objc
7663 , _appDelegateConfig_appDelegateNotificationConfig :: AppDelegateNotificationConfig
7764 , _appDelegateConfig_developerExtrasEnabled :: Bool
78− -- ^ Allow devtools in the app. Defaults to 'True'
79− , _appDelegateConfig_applicationOpenFile :: CString -> IO Bool
80− -- ^ Called when the app is launched by opening a file. 'CString' contains
81− -- the file path. Return value is 'True' if the file was successfully
82− -- opened. Defaults to ignoring the file and returning 'False'.
83− --
84− -- The Core Foundation plist key CFBundleDocumentTypes controls which file
85− -- types should be associated with the app.
8665 }
8766
8867instance Default AppDelegateConfig where
@@ -96,10 +75,8 @@ instance Default AppDelegateConfig where
9675 , _appDelegateConfig_applicationWillTerminate = return ()
9776 , _appDelegateConfig_applicationSignificantTimeChange = return ()
9877 , _appDelegateConfig_applicationUniversalLink = \_ -> return ()
99− , _appDelegateConfig_applicationDidReceiveRemoteNotification = \_ _ -> return ()
10078 , _appDelegateConfig_appDelegateNotificationConfig = def
10179 , _appDelegateConfig_developerExtrasEnabled = True
102− , _appDelegateConfig_applicationOpenFile = \_ -> return False
10380 }
10481
10582data AuthorizationOption = AuthorizationOption_Badge
@@ -108,12 +85,6 @@ data AuthorizationOption = AuthorizationOption_Badge
10885 | AuthorizationOption_CarPlay
10986 deriving (Show, Read, Eq, Ord)
11087
111−data ApplicationState = ApplicationState_Active
112− | ApplicationState_Inactive
113− | ApplicationState_Background
114− | ApplicationState_Unknown CInt
115− deriving (Show, Read, Eq, Ord)
116−
11788data AppDelegateNotificationConfig = AppDelegateNotificationConfig
11889 { _appDelegateNotificationConfig_requestAuthorizationWithOptions :: Maybe (Set AuthorizationOption)
11990 , _appDelegateNotificationConfig_registerForRemoteNotifications :: Bool
@@ -176,14 +147,6 @@ run' cfg main = do
176147 applicationWillTerminate <- newStablePtr $ _appDelegateConfig_applicationWillTerminate cfg
177148 applicationSignificantTimeChange <- newStablePtr $ _appDelegateConfig_applicationSignificantTimeChange cfg
178149 applicationUniversalLink <- newStablePtr $ _appDelegateConfig_applicationUniversalLink cfg
179− applicationDidReceiveRemoteNotification <- newStablePtr $ \n s -> do
180− let appState = case n of
181− 0 -> ApplicationState_Active
182− 1 -> ApplicationState_Inactive
183− 2 -> ApplicationState_Background
184− _ -> ApplicationState_Unknown n
185− _appDelegateConfig_applicationDidReceiveRemoteNotification cfg appState s
186− applicationOpenFile <- newStablePtr $ fmap fromBool . _appDelegateConfig_applicationOpenFile cfg
187150
188151 -- AppDelegate notification configuration
189152 let ncfg = _appDelegateConfig_appDelegateNotificationConfig cfg
@@ -206,7 +169,6 @@ run' cfg main = do
206169 applicationWillTerminate
207170 applicationSignificantTimeChange
208171 applicationUniversalLink
209− applicationDidReceiveRemoteNotification
210172 (fromBool requestAuthorizationWithOptions)
211173 (fromBool $ Set.member AuthorizationOption_Badge authorizationOptions)
212174 (fromBool $ Set.member AuthorizationOption_Sound authorizationOptions)
@@ -216,4 +178,3 @@ run' cfg main = do
216178 didRegisterForRemoteNotificationsWithDeviceToken
217179 didFailToRegisterForRemoteNotificationsWithError
218180 (fromBool $ _appDelegateConfig_developerExtrasEnabled cfg)
219− applicationOpenFile