@@ -4,12 +4,14 @@ module Language.Javascript.JSaddle.WKWebView.Internal
4 , jsaddleMainFile
4 , jsaddleMainFile
5 , WKWebView(..)
5 , WKWebView(..)
6 , mainBundleResourcePath
6 , mainBundleResourcePath
7+ , AppDelegateConfig (..)
9import Control.Monad (void, join)
10import Control.Monad (void, join)
10import Control.Concurrent (forkIO, forkOS)
11import Control.Concurrent (forkIO, forkOS)
11import Control.Concurrent.MVar (newEmptyMVar, putMVar, takeMVar)
12import Control.Concurrent.MVar (newEmptyMVar, putMVar, takeMVar)
13import Data.Monoid ((<>))
15import Data.Monoid ((<>))
14import Data.ByteString (useAsCString, packCString)
16import Data.ByteString (useAsCString, packCString)
15import qualified Data.ByteString as BS (ByteString)
17import qualified Data.ByteString as BS (ByteString)
@@ -29,7 +31,7 @@ newtype WKWebView = WKWebView (Ptr WKWebView)
29foreign export ccall jsaddleStart :: StablePtr (IO ()) -> IO ()
31foreign export ccall jsaddleStart :: StablePtr (IO ()) -> IO ()
30foreign export ccall jsaddleResult :: StablePtr (Results -> IO ()) -> CString -> IO ()
32foreign export ccall jsaddleResult :: StablePtr (Results -> IO ()) -> CString -> IO ()
31foreign export ccall withWebView :: WKWebView -> StablePtr (WKWebView -> IO ()) -> IO ()
33foreign export ccall withWebView :: WKWebView -> StablePtr (WKWebView -> IO ()) -> IO ()
32−foreign export ccall didRegisterForRemoteNotificationsWithDeviceTokenCallback :: CString -> StablePtr (CString -> IO ()) -> IO ()
34+foreign export ccall handlerCString :: CString -> StablePtr (CString -> IO ()) -> IO ()
33foreign import ccall addJSaddleHandler :: WKWebView -> StablePtr (IO ()) -> StablePtr (Results -> IO ()) -> IO ()
35foreign import ccall addJSaddleHandler :: WKWebView -> StablePtr (IO ()) -> StablePtr (Results -> IO ()) -> IO ()
34foreign import ccall loadHTMLString :: WKWebView -> CString -> IO ()
36foreign import ccall loadHTMLString :: WKWebView -> CString -> IO ()
35foreign import ccall loadBundleFile :: WKWebView -> CString -> CString -> IO ()
37foreign import ccall loadBundleFile :: WKWebView -> CString -> CString -> IO ()
@@ -86,11 +88,19 @@ withWebView webView ptrF = do
86 f <- deRefStablePtr ptrF
88 f <- deRefStablePtr ptrF
89−-- | A base64 encoded device token
90−didRegisterForRemoteNotificationsWithDeviceTokenCallback :: CString -> StablePtr (CString -> IO ()) -> IO ()
91+handlerCString :: CString -> StablePtr (CString -> IO ()) -> IO ()
91−didRegisterForRemoteNotificationsWithDeviceTokenCallback token f = do
92+handlerCString c fptr = do
92− f' <- deRefStablePtr f
93+ f <- deRefStablePtr fptr
96+data AppDelegateConfig = AppDelegateConfig
97+ { _appDelegateConfig_didRegisterForRemoteNotificationsWithDeviceToken :: CString -> IO ()
100+instance Default AppDelegateConfig where
101+ def = AppDelegateConfig
102+ { _appDelegateConfig_didRegisterForRemoteNotificationsWithDeviceToken = \_ -> return ()
95jsaddleJs :: ByteString
105jsaddleJs :: ByteString
96jsaddleJs = ghcjsHelpers <> "\
106jsaddleJs = ghcjsHelpers <> "\