1
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
|
||||
package="io.dcloud.uni_modules.xCallPhone">
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||
</manifest>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"minSdkVersion": "21"
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import Intent from 'android.content.Intent';
|
||||
import Uri from 'android.net.Uri';
|
||||
import Build from 'android.os.Build';
|
||||
import Activity from 'android.app.Activity';
|
||||
export function makePhone(tel : string) {
|
||||
let phone = "tel:" + tel;
|
||||
let ac = UTSAndroid.getUniActivity() as Activity
|
||||
let permissionCheck = ["android.permission.CALL_PHONE"]
|
||||
let _this = this;
|
||||
function callphone() {
|
||||
//10以上
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
let intent = new Intent(Intent.ACTION_DIAL, Uri.parse(phone))
|
||||
ac.startActivity(intent)
|
||||
// 10以下.
|
||||
} else {
|
||||
let intent = new Intent(Intent.ACTION_CALL, Uri.parse(phone))
|
||||
ac.startActivity(intent)
|
||||
}
|
||||
}
|
||||
if (UTSAndroid.checkSystemPermissionGranted(UTSAndroid.getUniActivity()!, permissionCheck)) {
|
||||
callphone()
|
||||
} else {
|
||||
console.log("当前不具备指定权限")
|
||||
UTSAndroid.requestSystemPermission(UTSAndroid.getUniActivity()!, permissionCheck, function (_ : boolean, _ : string[]) {
|
||||
callphone()
|
||||
}, function (_ : boolean, _ : string[]) {
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { call } from '@kit.TelephonyKit';
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
export function makePhone(tel : string) {
|
||||
call.makeCall(tel, (err : BusinessError) => {
|
||||
console.error(err.message)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSPrivacyAccessedAPITypes</key>
|
||||
<array/>
|
||||
<key>NSPrivacyCollectedDataTypes</key>
|
||||
<array/>
|
||||
<key>NSPrivacyTracking</key>
|
||||
<false/>
|
||||
<key>NSPrivacyTrackingDomains</key>
|
||||
<array/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"deploymentTarget": "12"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { URL } from 'Foundation';
|
||||
import { UIApplication } from 'UIKit';
|
||||
|
||||
export function makePhone(tel : string) {
|
||||
let phone = new URL(string = `tel://\(${tel})`);
|
||||
|
||||
if (UIApplication.shared.canOpenURL(phone!)) {
|
||||
|
||||
UIApplication.shared.open(phone!, options= new Map(), completionHandler= nil)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>LSApplicationQueriesSchemes</key>
|
||||
<array>
|
||||
<string>tel</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,8 @@
|
||||
export function makePhone(tel : string) {
|
||||
wx.makePhoneCall({
|
||||
phoneNumber:tel,
|
||||
fail(er) {
|
||||
console.error(er)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
export function makePhone(tel : string) {
|
||||
let isCanalinks = document.body.querySelector("#xPhoneAlinks")
|
||||
if (!isCanalinks) {
|
||||
let a = document.createElement("a")
|
||||
a.href = `tel:${tel}`
|
||||
a.id = "xPhoneAlinks"
|
||||
document.body.append(a)
|
||||
isCanalinks = a;
|
||||
}
|
||||
isCanalinks.click();
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user