@@ -4,12 +4,14 @@ module Language.Javascript.JSaddle.WKWebView.Internal
44 , jsaddleMainFile
55 , WKWebView(..)
66 , mainBundleResourcePath
7+ , AppDelegateConfig (..)
78 ) where
89
910import Control.Monad (void, join)
1011import Control.Concurrent (forkIO, forkOS)
1112import Control.Concurrent.MVar (newEmptyMVar, putMVar, takeMVar)
1213
14+import Data.Default
1315import Data.Monoid ((<>))
1416import Data.ByteString (useAsCString, packCString)
1517import qualified Data.ByteString as BS (ByteString)
@@ -29,7 +31,7 @@ newtype WKWebView = WKWebView (Ptr WKWebView)
2931foreign export ccall jsaddleStart :: StablePtr (IO ()) -> IO ()
3032foreign export ccall jsaddleResult :: StablePtr (Results -> IO ()) -> CString -> IO ()
3133foreign 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 ()
3335foreign import ccall addJSaddleHandler :: WKWebView -> StablePtr (IO ()) -> StablePtr (Results -> IO ()) -> IO ()
3436foreign import ccall loadHTMLString :: WKWebView -> CString -> IO ()
3537foreign import ccall loadBundleFile :: WKWebView -> CString -> CString -> IO ()
@@ -86,11 +88,19 @@ withWebView webView ptrF = do
8688 f <- deRefStablePtr ptrF
8789 f webView
8890
89−-- | A base64 encoded device token
90−didRegisterForRemoteNotificationsWithDeviceTokenCallback :: CString -> StablePtr (CString -> IO ()) -> IO ()
91−didRegisterForRemoteNotificationsWithDeviceTokenCallback token f = do
92− f' <- deRefStablePtr f
93− f' token
91+handlerCString :: CString -> StablePtr (CString -> IO ()) -> IO ()
92+handlerCString c fptr = do
93+ f <- deRefStablePtr fptr
94+ f c
95+
96+data AppDelegateConfig = AppDelegateConfig
97+ { _appDelegateConfig_didRegisterForRemoteNotificationsWithDeviceToken :: CString -> IO ()
98+ }
99+
100+instance Default AppDelegateConfig where
101+ def = AppDelegateConfig
102+ { _appDelegateConfig_didRegisterForRemoteNotificationsWithDeviceToken = \_ -> return ()
103+ }
94104
95105jsaddleJs :: ByteString
96106jsaddleJs = ghcjsHelpers <> "\