jlorente/laravel-appsflyer
Composer 安装命令:
composer require jlorente/laravel-appsflyer
包简介
Laravel 5.6 integration for the Jlorente Appsflyer package.
README 文档
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.
统计信息
- 总下载量: 6.16k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2018-05-29