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

package.cjs.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":["_devices","_interopRequireDefault","require","_registerServiceWorker","createBrowserSubscription","_ref","_asyncToGenerator2","_regenerator","mark","_callee","subscription","payload","wrap","_callee$","_context","prev","next","device","platform","devicesApi","create","localStorage","setItem","JSON","stringify","toJSON","keys","auth","t0","logger","error","stop","_x","apply","arguments","destroyBrowserSubscription","_ref2","_callee2","deviceId","_callee2$","_context2","unsubscribeBrowserNotifications","parse","getItem","destroy","removeItem","exports","registerBrowserNotifications","_ref3","_callee3","vapidPublicKey","response","_args3","_callee3$","_context3","length","undefined","process","env","VAPID_PUBLIC_KEY","registerServiceWorker","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":";;;;;;;;;AAIA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AALA;AACA;AACA;;AAQA,IAAME,yBAAyB;EAAA,IAAAC,IAAA,OAAAC,kBAAA,2BAAAC,YAAA,YAAAC,IAAA,CAAG,SAAAC,QAAMC,YAAY;IAAA,IAAAC,OAAA;IAAA,OAAAJ,YAAA,YAAAK,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,OAEzDG,mBAAU,CAACC,MAAM,CAACT,OAAO,CAAC;QAAA;UAChCU,YAAY,CAACC,OAAO,CAClB,UAAU,EACVC,IAAI,CAACC,SAAS,CAACd,YAAY,CAACe,MAAM,EAAE,CAACC,IAAI,CAACC,IAAI,CAAC,CAChD;UAACb,QAAA,CAAAE,IAAA;UAAA;QAAA;UAAAF,QAAA,CAAAC,IAAA;UAAAD,QAAA,CAAAc,EAAA,GAAAd,QAAA;UAEFe,MAAM,CAACC,KAAK,CAAC,8BAA8B,EAAAhB,QAAA,CAAAc,EAAA,CAAM;QAAC;UAAAd,QAAA,CAAAE,IAAA;UAAA;QAAA;UAGpDa,MAAM,CAACC,KAAK,CACV,wEAAwE,CACzE;QAAC;QAA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