{"_id":"@blumsoft/inbrain-cordova","_rev":"1-eebf6b42851ca46c9edae0a61413eb75","name":"@blumsoft/inbrain-cordova","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@blumsoft/inbrain-cordova","cordova_name":"Inbrain Cordova wrapper","title":"Inbrain Survey","version":"1.0.0","description":"Inbrain Cordova wrapper","types":"./src/typescript/index.d.ts","cordova":{"id":"@blumsoft/inbrain-cordova","platforms":["android","ios"]},"repository":{"type":"git","url":"git+https://github.com/inbrainai/inbrainCordova.git"},"bugs":{"url":"https://github.com/inbrainai/inbrainCordova/issues"},"keywords":["cordova","inbrain","survey"],"author":{"name":"Apache Software Foundation"},"license":"MIT License","licenseFilename":"LICENSE","main":"./src/typescript/index.js","platforms":["android","ios"],"engines":{"cordovaDependencies":{"3.0.0":{"cordova":">100"}}},"dependencies":{"plist":"^3.0.1"},"gitHead":"b9a11c2b05a831d1e83c1a699c2e18b14b691c65","homepage":"https://github.com/inbrainai/inbrainCordova#readme","_id":"@blumsoft/inbrain-cordova@1.0.0","_nodeVersion":"12.13.0","_npmVersion":"6.12.0","dist":{"integrity":"sha512-mQdmx47KAKhBCvYbqri6VTmNBPnxXI4G0GcZ+cFzr1EAdO63xs/EGx2gQyDXmBkdNfp3x63mAmr2I7/UU4+TFA==","shasum":"c6aaa809e553619613d79fc57fb68a2c8a9380c4","tarball":"https://registry.npmjs.org/@blumsoft/inbrain-cordova/-/inbrain-cordova-1.0.0.tgz","fileCount":98,"unpackedSize":4207115,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfH+JxCRA9TVsSAnZWagAAWzMP/1iM2N6MjFJ7odc8yOzs\nERgNDa0ALPiutpECwuw0rK2SewxMhh8ri6e0kbEFUSNeyL79wPmiiRSEn84m\nWg3AnBrvMrHes7kazkZzh2ycebh1LaZgF+Ugna4O9kNvr1ICZIC5MtaGoSXn\nNYoIHpGxCqMxz6nHLDwXV/waongcmBm94H9xFajuAt2Ti6RaaohjlU4PXhy4\n9IGgHDHJ2NQ2Deluy4GWooOhDqx+oAAJgOcips0UnIPqIU0iQVApx2lsAGJS\ntFa8kEZfjMRLO6JBv35Ov2p05BMbJRIXfwGStELSPu2Szb66Y13CZhsI1QeY\nM/Z+3UTiqh30YZDcPExWfJbmZf6FednckJChWjXHhObcKzkHl0DHkY+4HsWO\n/J7oVK9UvnQhFxWSkxfgNHZalU5CDm6+MsfInEoeSvh63tqZL3A5ifCENEXC\nsWBynp1xcAk1+ii50gdBWKUHnlU5Z6/iaw9eM8iz/HoaXuHUBk5OKG9VMHmP\nSVL0/Z2I3HkE+0jDCUMYIY/5ipV0L2tYH46BzRdMG1XC6jvn8j1pBMuQbiLG\nXc1SClRLYffe+wfMRqEzcXHlV1B223xA+D0BxELAplcUDQPJ8nR7t3GSh/nb\n0+us6L7K0DTYTvRilr9kQWpf5NcD538m24ga9sVwQqFg/o4kqYeXUFJ61P1a\nKgv7\r\n=+74a\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCwVLC5sMk+fJQNFO+agOMA1og5yfKyzN8WYF8pdNgxuQIgGkPNr8Hdr15xj7aMhfLcfxpYOGTN4ZclBhN/XwlrIXo="}]},"maintainers":[{"name":"laszloblum","email":"laszlo.70.blum@gmail.com"}],"_npmUser":{"name":"laszloblum","email":"laszlo.70.blum@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/inbrain-cordova_1.0.0_1595925104559_0.5049177298528271"},"_hasShrinkwrap":false}},"time":{"created":"2020-07-28T08:31:44.298Z","1.0.0":"2020-07-28T08:31:44.783Z","modified":"2022-04-04T19:50:29.198Z"},"maintainers":[{"name":"laszloblum","email":"laszlo.70.blum@gmail.com"}],"description":"Inbrain Cordova wrapper","homepage":"https://github.com/inbrainai/inbrainCordova#readme","keywords":["cordova","inbrain","survey"],"repository":{"type":"git","url":"git+https://github.com/inbrainai/inbrainCordova.git"},"author":{"name":"Apache Software Foundation"},"bugs":{"url":"https://github.com/inbrainai/inbrainCordova/issues"},"license":"MIT License","readme":"# inBrainCordova Cordova Plugin\n\nUse this plugin to integrate native inBrain SDKs in your iOS and Android Cordova apps.\nIn addition to Javascript, the plugin also provides a TypeScript type definitions.\n\n## Compatibility\n\nThe plugin is compatible with Cordova 8+ / cordova-ios 4.5+ / cordova-android 8.0+ / iOS 10+ / Android 5+.\n\n## Preparation\n\n### Installing plugin\n\n1. Clone the plugin into a folder beside your Cordova app from https://github.com/inbrainai/inbrainCordova.\n2. Goto your Cordova app's root folder and issue the command\n\n```\n\n ionic cordova plugin add ../inbrainCordova\n\n```\n\n### Setting up your ionic project\n\nTo use the plugin, import the followings.\n\n\n```\nimport InBrainCordova from \"inbrain-cordova\";\nimport * as InBrain from \"inbrain-cordova\";\n\n@Component({\n  selector: 'page-home',\n  templateUrl: 'home.html'\n})\nexport class HomePage {\n...\n```\n\n\n## InBrainCordova\nInBrainCordova class represents the wrapper of the InBrain SDK for Cordova.\nWe have the following methods\n\n### init\nInitializes the SDK.\nUse this method after platform ready.\n\n```\nInBrainCordova.init(\n        <<API_CLIENT_ID>>,\n        <<API_SECRET>>,\n        <<S2S>>, \n        <<USER_ID>>,\n        <<SESSION_ID>>,\n        <<InitOptions>>\n      ): Promise<void>\n```\n\nwhere the parameters are the following:\n```\nAPI_CLIENT_ID:\nThe apiCientID provided in inBrain.ai dashboard\n\nAPI_SECRET:\nThe apiSecret provided in inBrain.ai dashboard\n\nS2S:\nBool value. true if it is a server-to-server communication.\n\nUSER_ID:\nUser ID\n\nSESSION_ID:\nSession ID.\n\n\nInitOptions:\n\ntype ConfigOptionName = \"sessionID\" | \"userID\" | \"dataOptions\";\ntype StylingOptionName = \"title\" | \"navbarColor\";\ntype InitOptionName = ConfigOptionName | StylingOptionName;\ntype ConfigOptionTypes = {\n    sessionID: string;\n    userID: string;\n    dataOptions: DataOptions;\n};\ntype ConfigOptions = {\n    [opt in ConfigOptionName]?: ConfigOptionTypes[opt];\n};\ntype StylingOptionType = {\n    title: string;\n    navbarColor: string;\n};\ntype StylingOptions = {\n    [opt in StylingOptionName]?: StylingOptionType[opt];\n};\ntype InitOptions = ConfigOptions & StylingOptions;\n```\n\nExample:\n```\nInBrainCordova.init(\n        \"c0bbffc5-3c2b-44e7-a89e-f720c1a5867f\",\n        \"5iwiMGX3nWBLtNFHDinib7OfHb1mLUVII9x6Q+5bCLT+CMZZ9YbN9MWdywT/rfGFkmvRV+EwD2ltTAFzGGx1lQ==\",\n        false,\n        \"testing@test.com\",\n        \"testing@test.com\",\n        {\n          dataOptions: data,\n          title: \"Test title\",\n          navbarColor: \"#FF00FF\"\n        }\n      ).then(() => {\n        console.log(\"Init success...\");\n        // ...\n      })\n      .catch((err: InBrain.InBrainError) => {\n        console.log(\"Error happened in init: \" + JSON.stringify(err))\n      })\n```\n\nFields for init options:\n```\ntitle: string;\nThe title of the Surveys' nav bar.\n\nnavbarColor: string;\nThe color of the nav bar in hexcode string.\n\ndataOptions: DataOptions;\nArray of key-value pairs of strings to provide InBrain profiler data for custom profiler user experience.\ne.g.\n{ age : “23”, gender : “female” }\n\n```\n\n### showSurveys\n\nShows surveys.\n\n```\nInBrainCordova.showSurveys(): Promise<void>\n```\n\n### getRewards\n\nGet the details of all the rewards, in case the server mode is YES.\n\n```\nInBrainCordova.getRewards(): Promise<InBrainReward[]>\n```\n\nWhere InBrainReward is\n```\ntype InBrainReward = {\n    transactionId: number;\n    amount: number;\n    currency: string;\n    transactionType: number;\n};\n```\n\n### Callback functions\n\nThe survey SDK can trigger some events that we can get through callbacks.\nTo take effect, the callbacks needs to set by the following method.\n\n#### setListeners\nSets the callbacks.\n\n```\nstatic setListeners(callbacks: InBrainCallbacks): Promise<void>;\n```\nWhere InBrainCallbacks is defined like\n```\ntype InBrainCallbacks = {\n    surveyClosed: () => void,\n    rewardsReceived: (rewards: InBrainReward[]) => void\n};\n```\n\nsurveyClosed:\nTriggered when the survey is closed\n\nrewardsReceived:\nTriggered when new rewards are received.\n\n\nExample:\n```\nInBrainCordova.setListeners({\n            surveyClosed : () => {\n              console.log(\"inBrain form is closed\")\n            },\n            rewardsReceived: (rewards: [InBrain.InBrainReward]) => {\n              console.log(\"inBrain receive a reward: \" + JSON.stringify(rewards));\n              this.zone.run(() => {\n                this.numTokens = this.getTokens(rewards);\n              })\n            }\n          })\n          .then(() => {\n            console.log(\"Callback setListeners successfully set\");\n          })\n          .catch((err: InBrain.InBrainError) => {\n            console.log(\"setListeners error: \" + JSON.stringify(err));\n          });\n```","readmeFilename":"README.md"}