I've created a shopify app with PHP. and registered a webhook for 'app/uninstalled'. Which will remove data from my database.
But when I delete this app the webhook isn't triggering. Because the store isn't removing from my database.
Here is my code:
`POST /admin/webhooks.json 'webhook' => array( "topic" => "app/uninstalled", "address" => "https://my-domain/apps/app-name/uninstall.php", "format" => 'json', ),`
Can anyone tell me what is the problem and what things should I need to edit?
I've tried for a long time but now I'm stuck with this....
While I won't be as much help with the PHP coding itself in all honesty - if you could provide the shop you've uninstalled the app from and the timeframe in which it happened, I'd gladly check our logs here for you to ensure the webhook is firing as expected.
From my interpretation of $_POST (which I found here) this will also only work properly when application/x-www-form-urlencoded or multipart/form-data are used as the Content-Type in the request, and webhooks from us should be sending application/json as the Content-Type instead. I could be misinterpreting this though given that I'm not a PHP developer.
Perhaps that would explain the issue here? As Felix mentioned though I'd definitely recommend checking out your own server logs as well, I think the answer to this will probably be found there.
I'm not sure if this is related but today we noticed that we stopped getting uninstallation webhooks. We're 100% certain the webhook is installed and it was working perfectly before yesterday and we didn't change anything.
Other webhooks are working fine, it's just the uninstall one. We're not even seeing a request come from Shopify at all.
I checked the webhook logs this morning and it looks like SOME stores are dispatching webhook requests for uninstallations but many are not still.
There are still stores that certainly uninstalled yesterday that still have not received uninstall webhooks.
This would be a minor issue however it is actaully a BIG issue for us because many merchants install then re-install apps in an attempt to test things out, but unless we know that they uninstalled the app we don't know to refresh API details the second time they access the app.
I'm going to escalate this to Shopify further since it's clearly an issue on their end.
OK another update: it looks like they're working now for all new uninstalls, but old stores that were uninstalled for a short period didn't get webhooks called on them.
We'll have to go clean them up manually.
I'll post back if I see the issue come up again for future uninstalls.