# 模組呼叫方式 [Toc] ## 模組呼叫方式(使用任何模組之前必讀) **簡介** 本系統模組根據調用的情境不同,共分為_**“在嵌套Iframe中呼叫”**_以及在_**“無iframe下呼叫”**_兩種呼叫情境,以下將會詳細說明調用方式。 **在嵌套Iframe中呼叫** 本系統會預先在網頁中注入JS函式且無須擔憂Flutter端是否已經正確被加載完成,所以若是在嵌套中的iframe呼叫時,就只需要呼叫預先注入的函式名稱。如下事例,其中 `getGPSInfo` 為模組名稱,若是要調用其他模組更換其模組名稱便可以正常調用。 ``` window.parent.getGPSInfo().then(function(result){ console.log(JSON.stringify(result)) }) ``` **無iframe下呼叫** 在Hybrid App 中的JS Bridge當中,在交互之前必須先確認雙方已經被正確加載。所以在呼叫任何原生提供之模組時,必須先行監聽 `flutterInAppWebViewPlatformReady` 事件判斷 Flutter 模組是否已經被正確載入。如下例,其中 `getGPSInfo` 為模組名稱,若是要調用其他模組更換其模組名稱便可以正常調用。 ``` window.addEventListener("flutterInAppWebViewPlatformReady", function(event) { window.flutter_inappwebview.callHandler('GetDeviceInfo') }); ``` --- ## 模組介紹 ### LogoutExtention **簡介** 用於清除APP端用戶登入資訊(帳號、密碼),保留登入網址。在清除資料後,將APP頁面跳轉到登入頁面。 **使用方式** ``` // 在使用之前請先看模組使用說明 LogoutExtention() ``` --- ### IsFlutter **簡介** 回傳是由APP端瀏覽。回傳內容為true(Bool)。 **使用方式** ``` // 在使用之前請先看模組使用說明 IsFlutter() // true (bool) ``` --- ### ImagePickerExtention-選擇圖片上傳 **簡介** 以base64(String)格式回傳照片。 **使用方式** ``` // 在使用之前請先看模組使用說明 // 'data:image/png;base64,'; imagePicker() // String(Base64 format) ``` --- ### VideoPickerExtention-選擇影片上傳 **簡介** 以base64(String)格式回傳影片。 **使用方式** ``` // 在使用之前請先看模組使用說明 // 'data:video/mp4;base64,' videoPicker() // String(Base64 format) ``` --- ### photoCamera-拍照功能 **簡介** 回傳是由APP端瀏覽。回傳內容為true(Bool)。 **使用方式** ``` // 在使用之前請先看模組使用說明 // 'data:image/png;base64,'; photoCamera() // String(Base64 format) ``` --- ### videoRecorder-錄影功能 **簡介** 回傳是由APP端瀏覽。回傳內容為true(Bool)。 **使用方式** ``` // 在使用之前請先看模組使用說明 // 'data:video/mp4;base64,' IsFlutter() // true (bool) ``` --- ### GetDeviceInfo #### 共同資訊 |資訊名稱|Android對應欄位|IOS對應欄位|IOS範例|Android範例| |---|---|---|---|---| |name|build.model|data.name|My Phone|MI 9| |model|build.device|data.model|iPhone|Mi 9| |systemName|build.version.baseOS|data.systemName|iOS|Xiaomi MI 9 Android 10| |uuid|build.androidId|data.identifierForVendor|7946DA4E-8429-423C-B405-B3FC77914E3E|8af8770a27cfd182| |systemVersion|build.version.release|data.systemVersion|14.7.1|10| |manufacturer|build.manufacturer||APPLE|Xiaomi|