Skip to content

Commit d2ec505

Browse files
committed
fix: plugin not working on ios
1 parent 4a0cf90 commit d2ec505

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

Diff for: README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# capacitor-plugin-call
22

3-
Call number plugin for Capacitor apps
3+
Call number plugin for Capacitor apps (Capacitor 5 only).
4+
5+
## Supported platforms
6+
7+
- Android
8+
- iOS
49

510
## Install
611

Diff for: ios/Plugin/CallPlugin.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
// Define the plugin using the CAP_PLUGIN Macro, and
55
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
66
CAP_PLUGIN(CallPlugin, "Call",
7-
CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
7+
CAP_PLUGIN_METHOD(call, CAPPluginReturnPromise);
88
)

Diff for: ios/Plugin/CallPlugin.swift

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Foundation
12
import Capacitor
23

34
/**
@@ -14,13 +15,19 @@ public class CallPlugin: CAPPlugin {
1415
return
1516
}
1617

17-
if formattedNumber.starts(with:"tel:") {
18+
if !formattedNumber.starts(with:"tel:") {
1819
formattedNumber = "tel:" + formattedNumber
1920
}
2021

2122
formattedNumber = formattedNumber.replacingOccurrences(of: "#", with: "%23")
22-
guard let number = URL(string:formattedNumber) else { return }
23-
UIApplication.shared.open(number)
24-
call.resolve()
23+
guard let number = URL(string:formattedNumber)
24+
else {
25+
call.reject("error-call-failed")
26+
return
27+
}
28+
DispatchQueue.main.async {
29+
UIApplication.shared.open(number)
30+
call.resolve()
31+
}
2532
}
2633
}

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "capacitor-plugin-call",
3-
"version": "5.0.0",
3+
"version": "5.0.1",
44
"description": "Call number plugin for Capacitor apps",
55
"main": "dist/plugin.cjs.js",
66
"module": "dist/esm/index.js",

0 commit comments

Comments
 (0)