How to subscribe any webhook in shopify remix

How to subscribe any webhook in shopify remix

weebySagar
Shopify Partner
17 1 3

so in the shopify docs its saying that we can subscribe to webhook using app configuration file (toml) or using the API  in the shopify.server file. 


so in the toml file there is already an webhook for app uninstalled config like this

[webhooks]
api_version = "2024-07"

[[webhooks.subscriptions]]
topics = [ "app/uninstalled" ]
uri = "/webhooks"

 

 if I uninstall my app nothing is happening in the webhooks routes

but if I add in the shopify server file like this its working dont know why ?

 

 

const shopify = shopifyApp({
  apiKey: process.env.SHOPIFY_API_KEY,
  apiSecretKey: process.env.SHOPIFY_API_SECRET || "",
  apiVersion: ApiVersion.July24,
  scopes: process.env.SCOPES?.split(","),
  appUrl: process.env.SHOPIFY_APP_URL || "",
  authPathPrefix: "/auth",
  sessionStorage: new MongoDBSessionStorage(process.env.mongodb_url),
  distribution: AppDistribution.AppStore,
  restResources,
  future: {
    unstable_newEmbeddedAuthStrategy: true,
  },
  ...(process.env.SHOP_CUSTOM_DOMAIN
    ? { customShopDomains: [process.env.SHOP_CUSTOM_DOMAIN] }
    : {}),
  webhooks: {
    APP_UNINSTALLED: {
      deliveryMethod: DeliveryMethod.Http,
      callbackUrl: "/webhooks",
    },
  },
  hooks: {
    afterAuth: async ({ session }) => {
      shopify.registerWebhooks({ session });
    },
  },
});

 

 

Replies 0 (0)