Sometimes your app needs to do more than just show a number—it needs to breathe life into it and send it straight into your device’s native dialer. In the world of the browser, the magic incantation is simple:
tel:+123456
But inside a NativePHP app, this spell goes unheard—NativePHP doesn’t yet recognize the tel: scheme by itself.
So how do we coax the dialer to open?
We build a small ritual of our own: a button that travels through Laravel, whispers the number to a controller, and calls on the device’s dialer with the proper command.
Here’s how you can make your app’s phone numbers come alive.
🌺 Step 1: The Glyph (the View)
<x-link class="btn top-bg w-100 border-1 text-decoration-none" href="/trigger-pstn-dialer?number=123456"><span class="text-white small fw-bold">123456</span></x-link>
🌊 Step 2: The Vessel (the Blade Component)
<a {{ $attributes->merge(['class' => 'btn top-bg fw-bold']) }}><span class="text-white small">{{ $slot }}</span></a>
🔮 Step 3: The Gateway (the Route)
Route::get('/trigger-pstn-dialer', [NativeElementController::class, 'TriggerPstnDialer']);
🐉 Step 4: The Summoner (the Controller)
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Native\Mobile\Facades\Browser;
/**
* Class NativeElementController
* @package App\Http\Controllers
*/
class NativeElementController extends Controller
{
/**
* @param Request $request
* @return RedirectResponse
*/
public function TriggerPstnDialer(Request $request): RedirectResponse
{
$number = $request->input('number') ?? '';
Browser::open('tel:+' . $number);
return redirect('/');
}
}