Reputation: 4934
I generated new webhook into my app by run shopify generate webhook
. After that I see this code is created
config.webhooks = [
{topic: 'checkouts/create', address: 'https://66562fbc5033.ngrok.io/webhooks/checkouts/create', format: 'json'},
{topic: 'carts/update', address: 'https://66562fbc5033.ngrok.io/webhooks/carts/update', format: 'json'},
{topic: 'carts/update', address: 'https://66562fbc5033.ngrok.io/webhooks/carts/create', format: 'json'},
{topic: 'app/uninstalled', address: 'https://66562fbc5033.ngrok.io/webhooks/app/uninstalled', format: 'json'},
]
Then I goto my shop and add new webhook from Settings -> Notifications -> Create new webhook But seem it's not working.
This is controller
class HomeController < AuthenticatedController
def index
@products = ShopifyAPI::Product.find(:all, params: { limit: 10 })
@webhooks = ShopifyAPI::Webhook.find(:all)
end
end
This is template file
<h2>Webhooks</h2>
<% if @webhooks.present? %>
<ul>
<% @webhooks.each do |webhook| %>
<li><%= webhook.topic %> : <%= webhook.address %></li>
<% end %>
</ul>
<% else %>
<p>This app has not created any webhooks for this Shop. Add webhooks to your ShopifyApp initializer if you need webhooks</p>
<% end %>
This is what's displayed in my app
So what am I missing? any help!
Upvotes: 1
Views: 1056
Reputation: 907
When the OAuth callback is completed successfully, ShopifyApp will queue a background job which will ensure all the specified webhooks exist for that shop (Reference).
Do you have sidekiq or something similar running in the background? If not make sure you set something up, that's probably what you need.
You may read more about Rails Active Job here.
Upvotes: 2