PHP code example of rajen / nativephp-url-launcher

1. Go to this page and download the library: Download rajen/nativephp-url-launcher library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rajen / nativephp-url-launcher example snippets


use Rajen\UrlLauncher\Facades\UrlLauncher;


// Send an email
UrlLauncher::openEmail('[email protected]', 'Support Request', 'Hello from my app!');

// Dial a phone number
UrlLauncher::openPhone('+1234567890');

// Send an SMS
UrlLauncher::openSms('+1234567890', 'Please reply to this message.');

// Open WhatsApp
UrlLauncher::openWhatsApp('+1234567890', 'Hello!');

// Open Maps
UrlLauncher::openMap('London, UK');

// Open custom app deep link
UrlLauncher::openCustomScheme('myapp://product/123');

// Check if a URL can be launched
if (UrlLauncher::canLaunch('twitter://user?screen_name=NativePHP')) {
    UrlLauncher::launch('twitter://user?screen_name=NativePHP');
}

use Rajen\UrlLauncher\Events\UrlLaunched;
use Rajen\UrlLauncher\Events\UrlLaunchFailed;
use Rajen\UrlLauncher\Events\DeepLinkReceived;
use Rajen\UrlLauncher\Events\UrlLaunchCompleted;
use Illuminate\Support\Facades\Event;

Event::listen(function (DeepLinkReceived $event) {
    // do something
});
bash
php artisan vendor:publish --tag="nativephp-url-launcher-config"