-
-
Notifications
You must be signed in to change notification settings - Fork 113
After Authentication Job
For some apps, you may want something to fire after installation or authentication of a shop to the app. Some usecases:
- Sending a welcome email to the shop owner
- Configuring some extra database needs
- Uploading assets to a theme on install
First, open config/shopify-app.php
in your Laravel directory and search for After Authenticate Job
in that file so you're at the right location.
php artisan make:job {YourJobName}
Example:
php artisan make:job AfterAuthenticateJob
In config/shopify-app.php
you'll find something like:
'after_authenticate_job' => [
'job' => '',
'inline' => false,
],
Simply replace job
with the namespace to your job class. Example: \App\Jobs\AfterAuthenticateJob::class
.
The inline
option is for running the job immediately (inline) or dispatching it to a queue to run later. Most use cases you will leave this as false to dispatch to a queue. If you need to run something before the user accesses your app (like database setup, asset installs) that simply can't wait before the screen loads, then set inline
to be true
to run immediately.
The job you configure will run every time a shop installs the app and it will run every time they access the app through Shopify in a new session. If you wish this job to run only once on install, then you will need to track this on your own in the job, through something like the database to keep track if the job ran for that specific shop.