How to detect platform - Samsung/cordova-plugin-toast GitHub Wiki
This is a tip for using to not supported APIs by TOAST APIs.
When you need to realize by platform, You can use the following.
-
Make a new file. (ex. test.js)
-
Insert device apis as you want in self-invoking function.
(function (window) { var platform = cordova.require('cordova/platform'); switch(platform.id) { case 'sectv-orsay': var SEF = cordova.require('cordova/plugin/SEF'); var sefNetwork = SEF.get('Network'); window.getMACAddr = function () { return sefNetwork.Execute('GetMAC'); }; // Multi-App window.onPause = function (event) { console.log('Event type = ' + event.type); // deliver to 'onPause' }; window.onResume = function(event) { console.log('Event type = ' + event.type); // deliver to 'onResume' console.log('Parameter = ' + event.data); // deliver to same form as window.location.search }; break; case 'sectv-tizen': window.getMACAddr = function () { return webapis.network.getMac(); }; // Multi-App document.addEventListener('visibilitychange', function() { if(document.hidden) { webapis.avplay.suspend(); } else { webapis.avplay.restore(); } }); break; case 'tv-webos': break; } })(this);
-
Include the new file in index.html.
<script src='test.js'></script>
-
Use the API.
if(typeof window.getMACAddr === 'function') { TV_MAC = window.getMACAddr(); }