This article is the official HTML5 training course of the H5EDU organization. It mainly introduces: JavaScript Intensive Course - Native.js Example Summary
Although Native.js is powerful and open, many web developers cannot complete it independently because they are not familiar with the native API.
The purpose of this post is to summarize various written NJS codes for the convenience of web developers.
Everyone gathers firewood and the flame is high, and capable developers submit NJS code a lot, and everyone will give you a thumbs up.
Android platform Create and delete App shortcuts
on the desktop.
See the Native.js part of the demo and source code in Hello H5+.
Or search for "shortcut" here, http://ask.dcloud.net.cn/docs/ ... le/88
Call Android local sharing
http://ask.dcloud.net.cn/article/134
Dial directly Call
http://ask.dcloud.net.cn/question/4035
to switch the program to the background
http://ask.dcloud.net.cn/question/2484
Force pop up the soft keyboard
http://ask.dcloud.net. cn/question/2324
Get Android device device.uuid
http://ask.dcloud.net.cn/question/3510
Get memory and CPU information
http://ask.dcloud.net.cn/question/2202Turn
on and off bluetoothhttp
://ask.dcloud.net.cn/question/4720Monitor
bluetooth switch
statushttp://ask.dcloud.net.cn/article /274
Get list of bluetooth devices
http://ask.dcloud.net.cn/question/8265
NFC data read
http://ask.dcloud.net.cn/question/6726
Screenshot
http://ask.dcloud.net .cn/question/5344Get
MAC
addresshttp ://ask.dcloud.net.cn/question/1511Open
network settingshttp :
//ask.dcloud.net.cn/question/1475Open
location informationhttp
://ask .dcloud.net.cn/question/14731
Get WIFI list
http://ask.dcloud.net.cn/question/12113
Call system controls to play video
http://ask.dcloud.net.cn/question/614
Call os Address book selection controls
http://ask.dcloud.net.cn/question/5783
Insert native calendar reminder
http://ask.dcloud.net.cn/article/215
Call system controls to crop pictureshttp:
//ask.dcloud.net.cn /question/8314
Copy the content to the system clipboard
http://ask.dcloud.net.cn/question/2034
Call iFLYTEK’s text-to-speech function (TTS)
http://ask.dcloud.net.cn/question/ 6473
After calling other Activity, get the return result through startActivityForResult
http://ask.dcloud.net.cn/question/5783
Receive system broadcast messages, such as monitoring the event of installing and uninstalling apk
http://ask.dcloud.net.cn/article /222
Determine whether the app is installed
http://ask.dcloud.net.cn/question/7604
Take monitoring the airplane mode switch of the mobile phone as an example to illustrate how to use Native.js to broadcast the BroadcastReceiver
http://ask.dcloud.net.cn/ question/7661 resides
in the Android notification bar, and does not need a push to achieve local notification (Local Notification)
http://ask.dcloud.net.cn/question/2464
Call the native socket connection
http://ask.dcloud.net.cn/question/60
Start a native service
http://ask.dcloud.net.cn /question/433
Stop and start the push function
var pushManager = plus.android.importClass("com.igexin.sdk.PushManager");
var context = plus.android.runtimeMainActivity();
function enable() {
pushManager.getInstance ().turnOnPush(context);
}
function disable() {
pushManager.getInstance().turnOffPush(context);
}
Thanks to Yeahcheung for sharing
Use native.js to get whether the mobile phone gps is turned on
http://ask.dcloud.net.cn/ question/11890
Setting system wallpaper through native.js
http://ask.dcloud.net.cn/article/651
iOS platform
Get the package name
var NSBundle = plus.ios.importClass('NSBundle');
var bundle = NSBundle.mainBundle();
console.log(bundle.bundleIdentifier());
plus.ios.deleteObject(bundle);
get the device name
http ://ask.dcloud.net.cn/question/14691Test
whether to install an applicationhttp : //ask.dcloud.net.cn/question/14430Call the iOS print API
http://ask.dcloud.net.cn/ question/4226 Log in to the game center through native.js and see the demo and source code of Native.js in Hello H5+. Or search for "game center" here, http://ask.dcloud.net.cn/docs/ ... le/88 Set to get content to the system clipboard http://ask.dcloud.net.cn/question/ 3720 Open the page by default and the keyboard will pop up http://ask.dcloud.net.cn/question/2324 Play the prompt tone http://ask.dcloud.net.cn/question/3962
Call ios text-to-speech (TTS)
http://ask.dcloud.net.cn/question/4175
Save the base64 data as a picture
http://ask.dcloud.net.cn/question/6190
Set the webview sliding deceleration
var webview = plus.ios.currentWebview();
var scrollView = webview.plusGetAttribute("scrollView");
scrollView.plusSetAttribute("decelerationRate:",0.99);
Open the Wifi setting page of ios
http://ask.dcloud.net .cn/question/7797Determine
whether to enable message notificationhttp :
//ask.dcloud.net.cn/question/4497Check whether
iOS allows the use of the camera (thanks for sharing)
http://ask.dcloud.net.cn/ article/188
ios gets the system's time zone id
var NSTimeZone = plus.ios.importClass("NSTimeZone");
var sys = NSTimeZone.systemTimeZone();
console.log(sys.plusGetAttribute("name"));
状态栏显示网络请求雪花
var UIApplication = plus.ios.import("UIApplication");
var sharedApplication = UIApplication.sharedApplication();
sharedApplication.setNetworkActivityIndicatorVisible(true);
plus.ios.deleteObject(sharedApplication);
获取GPS授权状态
var CLLocationManager = plus.ios.import("CLLocationManager");
var authorizationStatus = CLLocationManager.authorizationStatus();
switch(authorizationStatus) {
case 0:
/// User has not yet made a choice with regards to this application
break;
case 1:
// This application is not authorized to use location services. Due
// to active restrictions on location services, the user cannot change
// this status, and may not have personally denied authorization
break;
case 2:
// User has explicitly denied authorization for this application, or
// location services are disabled in Settings.
break;
case 3:
// User has granted authorization to use their location at any time,
// including monitoring for regions, visits, or significant location changes.
break;
case 4:
// User has granted authorization to use their location only when your app
// is visible to them (it will be made visible to them if you continue to
// receive location updates while in the background). Authorization to use
// launch APIs has not been granted.
break;
case 5:
// This value is deprecated, but was equivalent to the new -Always value.
break;
defalut:
break;
}
获取手机存储空间
var BundleClass = plus.ios.importClass("NSBundle");
var BundleObj = BundleClass.mainBundle();
var filenamagerobj = plus.ios.newObject("NSFileManager");
var FileAttr = plus.ios.invoke(filenamagerobj,"attributesOfFileSystemForPath:error:",BundleObj.bundlePath(),null);
// NSFileSystemFreeSize parameter gets the remaining space
// NSFileSystemSize gets the total storage space of the phone
var freeSpace = plus.ios.invoke(FileAttr,"objectForKey:","NSFileSystemFreeSize");
var numberFormatterObj = plus.ios.newObject("NSNumberFormatter");
var FreeSpaceStr = plus.ios.invoke(numberFormatterObj,"stringFromNumber:",freeSpace);
var freeSpace = FreeSpaceStr / 1024/1024/1024; After
reading these examples, do you think JS is particularly powerful?
Hurry up and use it!
JavaScript Intensive Tutorial - A Summary of Native.js Examples
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326838715&siteId=291194637
Recommended
Ranking