All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.react-utils.BrowserPushNotifications.pushHelper.js.map Maven / Gradle / Ivy

Go to download

A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.

There is a newer version: 4.12.3
Show newest version
{"version":3,"file":"pushHelper.js","names":["devicesApi","unsubscribeBrowserNotifications","registerServiceWorker","createBrowserSubscription","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","subscription","payload","wrap","_callee$","_context","prev","next","device","platform","create","localStorage","setItem","JSON","stringify","toJSON","keys","auth","t0","logger","error","stop","_x","apply","arguments","destroyBrowserSubscription","_ref2","_callee2","deviceId","_callee2$","_context2","parse","getItem","destroy","removeItem","registerBrowserNotifications","_ref3","_callee3","vapidPublicKey","response","_args3","_callee3$","_context3","length","undefined","process","env","VAPID_PUBLIC_KEY","sent"],"sources":["../../../src/react-utils/BrowserPushNotifications/pushHelper.js"],"sourcesContent":["// THIS FILE HAS BEEN ADDED BY NEETO NOTIFICATIONS ENGINE\n// AND IS USED FOR BROWSER NOTIFICATIONS\n// CONTACT NEETO NOTIFICATIONS TEAM BEFORE MODIFYING THIS FILE\n\nimport devicesApi from \"./devices\";\nimport {\n  unsubscribeBrowserNotifications,\n  registerServiceWorker,\n} from \"./registerServiceWorker\";\n\nconst createBrowserSubscription = async subscription => {\n  if (subscription) {\n    const payload = { device: { subscription, platform: \"browser\" } };\n    try {\n      await devicesApi.create(payload);\n      localStorage.setItem(\n        \"deviceId\",\n        JSON.stringify(subscription.toJSON().keys.auth)\n      );\n    } catch (err) {\n      logger.error(\"Device registration Failed: \", err);\n    }\n  } else {\n    logger.error(\n      \"Something went wrong while registering device for browser subscription\"\n    );\n  }\n};\n\nexport const destroyBrowserSubscription = async () => {\n  try {\n    await unsubscribeBrowserNotifications();\n    const deviceId = JSON.parse(localStorage.getItem(\"deviceId\"));\n    await devicesApi.destroy(deviceId);\n    localStorage.removeItem(\"deviceId\");\n  } catch (err) {\n    logger.error(\n      \"Something went wrong while unsubscribing browser notification:\",\n      err\n    );\n  }\n};\n\nexport const registerBrowserNotifications = async (\n  vapidPublicKey = process.env.VAPID_PUBLIC_KEY\n) => {\n  const response = await registerServiceWorker(vapidPublicKey);\n  await createBrowserSubscription(response);\n};\n"],"mappings":";;AAAA;AACA;AACA;;AAEA,OAAOA,UAAU;AACjB,SACEC,+BAA+B,EAC/BC,qBAAqB;AAGvB,IAAMC,yBAAyB;EAAA,IAAAC,IAAA,GAAAC,iBAAA,eAAAC,mBAAA,CAAAC,IAAA,CAAG,SAAAC,QAAMC,YAAY;IAAA,IAAAC,OAAA;IAAA,OAAAJ,mBAAA,CAAAK,IAAA,UAAAC,SAAAC,QAAA;MAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;QAAA;UAAA,KAC9CN,YAAY;YAAAI,QAAA,CAAAE,IAAA;YAAA;UAAA;UACRL,OAAO,GAAG;YAAEM,MAAM,EAAE;cAAEP,YAAY,EAAZA,YAAY;cAAEQ,QAAQ,EAAE;YAAU;UAAE,CAAC;UAAAJ,QAAA,CAAAC,IAAA;UAAAD,QAAA,CAAAE,IAAA;UAAA,OAEzDf,UAAU,CAACkB,MAAM,CAACR,OAAO,CAAC;QAAA;UAChCS,YAAY,CAACC,OAAO,CAClB,UAAU,EACVC,IAAI,CAACC,SAAS,CAACb,YAAY,CAACc,MAAM,EAAE,CAACC,IAAI,CAACC,IAAI,CAAC,CAChD;UAACZ,QAAA,CAAAE,IAAA;UAAA;QAAA;UAAAF,QAAA,CAAAC,IAAA;UAAAD,QAAA,CAAAa,EAAA,GAAAb,QAAA;UAEFc,MAAM,CAACC,KAAK,CAAC,8BAA8B,EAAAf,QAAA,CAAAa,EAAA,CAAM;QAAC;UAAAb,QAAA,CAAAE,IAAA;UAAA;QAAA;UAGpDY,MAAM,CAACC,KAAK,CACV,wEAAwE,CACzE;QAAC;QAAA;UAAA,OAAAf,QAAA,CAAAgB,IAAA;MAAA;IAAA,GAAArB,OAAA;E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