Skip to content

Commit

Permalink
fix: plugin not working on ios
Browse files Browse the repository at this point in the history
  • Loading branch information
khang-nd committed Sep 21, 2024
1 parent 4a0cf90 commit d2ec505
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# capacitor-plugin-call

Call number plugin for Capacitor apps
Call number plugin for Capacitor apps (Capacitor 5 only).

## Supported platforms

- Android
- iOS

## Install

Expand Down
2 changes: 1 addition & 1 deletion ios/Plugin/CallPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
// Define the plugin using the CAP_PLUGIN Macro, and
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
CAP_PLUGIN(CallPlugin, "Call",
CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(call, CAPPluginReturnPromise);
)
15 changes: 11 additions & 4 deletions ios/Plugin/CallPlugin.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
import Capacitor

/**
Expand All @@ -14,13 +15,19 @@ public class CallPlugin: CAPPlugin {
return
}

if formattedNumber.starts(with:"tel:") {
if !formattedNumber.starts(with:"tel:") {
formattedNumber = "tel:" + formattedNumber
}

formattedNumber = formattedNumber.replacingOccurrences(of: "#", with: "%23")
guard let number = URL(string:formattedNumber) else { return }
UIApplication.shared.open(number)
call.resolve()
guard let number = URL(string:formattedNumber)
else {
call.reject("error-call-failed")
return
}
DispatchQueue.main.async {
UIApplication.shared.open(number)
call.resolve()
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "capacitor-plugin-call",
"version": "5.0.0",
"version": "5.0.1",
"description": "Call number plugin for Capacitor apps",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down

0 comments on commit d2ec505

Please sign in to comment.