I've registered the app/uninstalled webhook and got a request in return. Everything is ok,
NOTE: ( flag is my column from the database )
flag=0 [ Uninstalled ]
flag=1 [ Installed ]
When flag=1 I'm redirecting my app to /index.php. And when flag=0 I'm redirecting to OAuth Installation Step.
So when app uninstalled I'm getting webhook request and I'm able to set flag=0. But sometimes I'm not getting webhook request so that time I'm not able to set flag=0 and instead of 0 by default it will be set 1. So as per the value of flag=1 means app is installed but I've just deleted.
Hope you guys understand this issue. Give me some solution ASAP.
Give me some solution ASAP.
The thing with webhooks is - they do not guarantee to give you a solution ASAP. In other words, they may or may not arrive (though Shopify does have retries) and likewise there is no time window within which they "should" arrive.
It's hard to understand your exact problem, but the fact that you are doing redirects or that you are handling the hook on the same endpoint as normal app requests is an accident waiting to happen. I would keep the app/uninstalled webhook handler completely separate. Also because the validation of webhook requests is different to that of oauth journey. The webhooks are called by Shopify servers. I don't think they would follow redirects.
Just dropping in to confirm @JazepsBasko's point. Our webhooks do not follow redirects, and we will interpret them as an error.