Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Event to notify Successful App Installation on the Store. #1058

Closed
wants to merge 7 commits into from
Closed

Event to notify Successful App Installation on the Store. #1058

wants to merge 7 commits into from

Conversation

abishekrsrikaanth
Copy link

@abishekrsrikaanth abishekrsrikaanth commented Jan 12, 2022

The AppInstalled event will be triggered after the installation of App on the store. This can be used to run jobs after successful installation. For example, fetching data from the store that is needed by the application.

Here is an example of how to set up a Listener and subscribe to it on the project's EventServiceProvider.

<?php

namespace App\Listeners;

use Osiset\ShopifyApp\Messaging\Events\AppInstalled;

class AppInstalledEventListener
{
    /**
     * Handle AppInstalled Event.
     *
     * @param  Osiset\ShopifyApp\Messaging\Events\AppInstalled $event
     * @return void
     */
    public function handle(AppInstalled $event)
    {
            $shop = $event->getShop();
            // Get Shop Details
            // Get Products
            // Get Collections
            // etc...
    }
}

Once your listener has been defined, you may register it within your application's EventServiceProvider:

<?php

namespace App\Providers;

use App\Listeners\AppInstalledEventListener;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Osiset\ShopifyApp\Messaging\Events\AppInstalled;

class EventServiceProvider extends ServiceProvider
{
    protected $listen = [
        AppInstalled::class => [
            AppInstalledEventListener::class,
        ],
    ];
}

@talktohenryj
Copy link

Cant you just do this with an AfterAuthentication Job? Thats how I do this today.

@Kyon147
Copy link
Collaborator

Kyon147 commented Sep 10, 2022

@osiset I'm going to close this in favor of keeping the AppInstalledJob and there's a lot of other code changed in here we've already merged in.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants