jlorente / laravel-appsflyer
Laravel 5.6 integration for the Jlorente Appsflyer package.
Installs: 5 332
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.1.3
- illuminate/support: >=5.5
- jlorente/appsflyer: dev-master
This package is auto-updated.
Last update: 2024-10-22 23:40:26 UTC
README
This extension allows you to access the Appsflyer API by a comprehensive way.
Installation
The preferred way to install this extension is through composer.
With Composer installed, you can then install the extension using the following commands:
$ php composer.phar require jlorente/laravel-appsflyer
or add
... "require": { "jlorente/laravel-appsflyer": "*" }
to the require
section of your composer.json
file.
Configuration
- Register the ServiceProvider in your config/app.php service provider list.
config/app.php
return [ //other stuff 'providers' => [ //other stuff \Jlorente\Laravel\Appsflyer\AppsflyerServiceProvider::class, ]; ];
- Add the following facade to the $aliases section.
config/app.php
return [ //other stuff 'aliases' => [ //other stuff 'Appsflyer' => \Jlorente\Laravel\Appsflyer\Facades\Appsflyer::class, ]; ];
- Set the dev_key and api_token in the config/services.php in a new created appsflyer array.
config/services.php
return [ //other stuff 'appsflyer' => [ 'dev_key' => 'YOUR_DEV_KEY', 'api_token' => 'YOUR_API_TOKEN', 'is_active' => true, ]; ];
Usage
You can use the facade alias Appsflyer to execute api calls. The authentication params will be automaticaly injected.
Appsflyer::inappevent()->create($data);
Notification Channel
A notification channel is included in this package and allows you to integrate the Appsflyer in app events service with the Laravel notifications.
Formatting Notifications
If a notification should trigger an Appsflyer in app event, you should define a toAppsflyer method on the notification class. This method will receive a $notifiable entity and should return a Jlorente\Laravel\Appsflyer\Notifications\Messages\AppsflyerMessage instance:
/** * Get the AppsflyerMessage that represents the notification. * * @param mixed $notifiable * @return \Jlorente\Laravel\Appsflyer\Notifications\Messages\AppsflyerMessage|string */ public function toAppsflyer($notifiable) { return (new AppsflyerMessage) ->platform('com.mycompany.myapp') ->payload([ 'eventName' => 'af_purchase' ]); }
Once done, you must add the notification channel in the array of the via() method of the notification:
/** * Get the notification channels. * * @param mixed $notifiable * @return array|string */ public function via($notifiable) { return [AppsflyerChannel::class]; }
You can find more info about Laravel notifications in this page.
License
Copyright © 2018 José Lorente Martín jose.lorente.martin@gmail.com.
Licensed under the BSD 3-Clause License. See LICENSE.txt for details.