jlorente/laravel-appsflyer

Laravel 5.6 对 Jlorente Appsflyer 包的集成。

dev-master 2020-09-22 14:53 UTC

This package is auto-updated.

Last update: 2024-09-22 23:31:10 UTC


README

此扩展允许您以全面的方式访问 Appsflyer API。

安装

安装此扩展的首选方式是通过 Composer

安装 Composer 后,您可以使用以下命令安装扩展

$ php composer.phar require jlorente/laravel-appsflyer

或添加

...
    "require": {
        "jlorente/laravel-appsflyer": "*"
    }

到您的 composer.json 文件的 require 部分。

配置

  1. 在 config/app.php 的服务提供者列表中注册 ServiceProvider。

config/app.php

return [
    //other stuff
    'providers' => [
        //other stuff
        \Jlorente\Laravel\Appsflyer\AppsflyerServiceProvider::class,
    ];
];
  1. 在 $aliases 部分添加以下外观。

config/app.php

return [
    //other stuff
    'aliases' => [
        //other stuff
        'Appsflyer' => \Jlorente\Laravel\Appsflyer\Facades\Appsflyer::class,
    ];
];
  1. 在 config/services.php 中创建新的 appsflyer 数组,设置 dev_key 和 api_token。

config/services.php

return [
    //other stuff
    'appsflyer' => [
        'dev_key' => 'YOUR_DEV_KEY',
        'api_token' => 'YOUR_API_TOKEN',
        'is_active' => true,
    ];
];

用法

您可以使用外观别名 Appsflyer 来执行 API 调用。认证参数将自动注入。

Appsflyer::inappevent()->create($data);

通知通道

此包中包含一个通知通道,允许您通过 Laravel 通知将 Appsflyer 集成到应用事件服务中。

格式化通知

如果通知应触发 Appsflyer 应用事件,您应在通知类中定义 toAppsflyer 方法。此方法将接收一个 $notifiable 实体,并应返回一个 Jlorente\Laravel\Appsflyer\Notifications\Messages\AppsflyerMessage 实例。

/**
 * 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'
                ]);
}

完成后,您必须在通知的 via() 方法的数组中添加通知通道。

/**
 * Get the notification channels.
 *
 * @param  mixed  $notifiable
 * @return array|string
 */
public function via($notifiable)
{
    return [AppsflyerChannel::class];
}

有关 Laravel 通知的更多信息,请参阅 此页面

许可

版权所有 © 2018 José Lorente Martín jose.lorente.martin@gmail.com.

许可协议为 BSD 3-Clause License。详情请见 LICENSE.txt。