1// JavaScript Document 2function sendToIos(command, data = null) { 3 return new Promise(function (resolve, reject) { 4 if (typeof window.webkit != 'undefined') { 5 dmx.global.set('nativeios', 1) // webkit present so native ios (use to hide/show elements on page) 6 var message = { 7 command: command, // the switch statment command when processing Swift e.g. oneSignalSetId 8 data: data // data object to accompany command e.g. {osId: 123} 9 }; 10 // "iosBridge" is the name you used for the message handler in Swift 11 window.webkit.messageHandlers.iosBridge.postMessage(message); 12 } 13 else { 14 dmx.global.set('nativeios', 0) // webkit not set so NOT native ios (use to hide/show elements on page) 15 } 16 return resolve(true); 17 }) 18} 19window.fromIOS = function (result) { 20 console.log("IOS Value:", result); 21 if (result.command === "iosVersion") { 22 dmx.global.set('iosAppVersion', result.message) 23 dmx.global.set('iosAppBuild', result.status) 24 } 25 26 if (result.command === "faceIdAvailable") { 27 if (result.status === "ready") { 28 // show button to use Face/Touch ID 29 dmx.global.set('touchId', 2) 30 } else if (result.status === "notCapable") { 31 // hide Face/Touch ID option from device 32 dmx.global.set('touchId', 0) 33 } else if (result.status === "notSet") { 34 // show option to enable Face/Touch ID after successful login 35 dmx.global.set('touchId', 1) 36 } else { 37 dmx.global.set('touchId', 0) 38 } 39 } 40 41 if (result.command === "saveCredentials") { 42 if (result.status === "saved") { 43 console.log("Credentials saved!"); 44 } else { 45 console.error("Failed to save credentials:", result.message); 46 } 47 } 48 if (result.command === "faceIdCleared") { 49 if (result.status === "empty") { 50 sendToIos('checkFaceId') 51 console.log("Credentials saved!"); 52 } else { 53 console.error("Failed to save credentials:", result.message); 54 } 55 } 56 57 if (result.command === "useLogin") { 58 if (result.status === "saved") { 59 console.log("Credentials saved!"); 60 } else { 61 console.error("Failed to save credentials:", result.message); 62 } 63 } 64};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.