{"_id":"@appsamurai/react-native-appsamurai-ads","_rev":"2-39f293d0c4f4d97b92baec185520b607","name":"@appsamurai/react-native-appsamurai-ads","dist-tags":{"latest":"0.0.10"},"versions":{"0.0.10":{"name":"@appsamurai/react-native-appsamurai-ads","version":"0.0.10","description":"A react-native component for AppSamurai Ads","author":{"name":"Olcay Ay","email":"olcayay@gmail.com"},"main":"index.js","license":"BSD-2-Clause","private":false,"repository":{"type":"git","url":"git@github.com/Netvent/react-native-appsamurai-ads.git"},"dependencies":{"prop-types":"^15.5.10"},"devDependencies":{"babel-eslint":"^7.2.3","eslint":"^4.3.0","eslint-plugin-react":"^7.1.0"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"gitHead":"32d34db3407d89e1eee6f80bbdf3f51dd020d723","_id":"@appsamurai/react-native-appsamurai-ads@0.0.10","_nodeVersion":"12.6.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-+5bYGsnZCXMuI08pswfEe3pPfkVdq8a78x2MHUEtVu0e07BIQObjP20NE1quCFishOZhnS6ebD+J77X4NuAU6Q==","shasum":"cf495154429d6262eef75ab7d1ee938c7f6b4147","tarball":"https://registry.npmjs.org/@appsamurai/react-native-appsamurai-ads/-/react-native-appsamurai-ads-0.0.10.tgz","fileCount":109,"unpackedSize":1366181,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdNNC5CRA9TVsSAnZWagAArPEP/jvgItes72SgIo0wdrGc\nmLgB4yiPXL3F+l7fDAba6ThWi7L8C9BnHBUeCVLtXQk1horjyQqUF2snNRQS\n/OwO7vjSl4cg54QKFUjW9DJl8nIHRj7EStPFeVuGmVxm3/CQB3wJgrPBlNfH\ns/9cM+fnf6fKC4SXegBDdfP2I/9JYw7qJBKOLxRgyOTrQNdwhM9WZm+MIgTW\nlyPH28dvNwqg2eiBT/YDgCGETZriU/j3ulyw1jeCmwNBfd0bRuxLsIcWDcNm\nrZdZ7gaC9/cZLXQqlzANzkLRbmsKeIrRHZvbULe3RDR+bUYGjuXi9r6PANzV\nyaTgXazTCEpGVktLUiUZGeB7zDzXMWHVpTrb4D38lNQ/QDgOGZCwbLsP+kcS\n741rvIDz6lw+tMWF5iv5xYtLxXxtYs0aVb+F2keVmy59sponqGLmBhQfyWSt\nX+ym6C8iz8w94ypJCAOWjtuOcAMO12rMvc1kZZ0bh6SSXTv3eaVKQEnt5+7Q\n9Xy8EfJrv2Mn7Sjo1yq6U8ITW+QUMMIIp1d2EnkjhmbFjc77iAFGOt0a273t\nL5wYLFmHzURASQfx8Jbyb+HZF92AALLBXETMLNvJZzKCOCAkthZr6xahZ7Ni\nwTa+lgzhSVb0Z6pm6VQMMS7ymXxoELxz6QAGgvFCeZfVyGc0saVaiGXe1xww\naRWN\r\n=omHJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCJu0PMfhjL6VFePDbmADVLwhpDAZ9fRdrglRGeUIpOigIhAPm6gPcjLNX5+HJW6XStfNwplCL3Q9xwltrsw2pyoKgB"}]},"maintainers":[{"name":"olcayay","email":"olcayay@gmail.com"}],"_npmUser":{"name":"olcayay","email":"olcayay@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-native-appsamurai-ads_0.0.10_1563742392300_0.40073251213284555"},"_hasShrinkwrap":false}},"time":{"created":"2019-07-21T20:53:12.095Z","0.0.10":"2019-07-21T20:53:12.449Z","modified":"2022-04-04T15:04:18.829Z"},"maintainers":[{"email":"mobile@appsamurai.com","name":"appsamuraiinc"},{"email":"olcayay@gmail.com","name":"olcayay"}],"description":"A react-native component for AppSamurai Ads","repository":{"type":"git","url":"git@github.com/Netvent/react-native-appsamurai-ads.git"},"author":{"name":"Olcay Ay","email":"olcayay@gmail.com"},"license":"BSD-2-Clause","readme":"A react-native module for AppSamurai Ads. \n\nWith this module you can use AppSamurai Ads and Google AdMob together without an extra configuration. Supported ad formats are Banner, Interstitial and Rewarded Video. The banner type is implemented as components while the interstitial and rewarded video have an imperative API.\n\n## Native AppSamurai Ad SDKs\nAppSamurai Ads has native SDKs both for iOS and Android.\n### iOS\n[`AppSamurai Ads iOS SDK`](https://github.com/Netvent/appsamurai-adsdk-ios)\n### Android\n[`AppSamurai Ads Android SDK`](https://github.com/Netvent/appsamurai-adsdk-android)\n\n## Installation\nYou can use npm to install this npm package\n``` shell\nnpm i --save react-native-appsamurai-ads\n```\n\nLinking library\n``` shell\nreact-native link react-native-appsamurai-ads\n```\n\nIn order to use this library, you have to link it to your project first. There's excellent documentation on how to do this in the [React Native Docs](https://facebook.github.io/react-native/docs/linking-libraries-ios.html#content).\n\n### iOS\n### Android\n\n## Usage\n\n### Banner\nImporting AppSamuraiBanner\n``` js\nimport {\n  AppSamuraiBanner\n} from 'react-native-appsamurai-ads';\n```\n\nAdding as react element\n``` js\n<AppSamuraiBanner\n    adSize=\"banner\"\n    adUnitID=\"appsamurai-sample-android-banner-ad-id\"\n    gadAdUnitID=\"ca-app-pub-3940256099942544/6300978111\"\n    testDevices={[\n      '<test-device-id-1>',\n      '<test-device-id-2>',\n      '<test-device-id-3>'\n    ]}\n    onAdLoaded={()=> {\n      this.setLog('AppSamuraiBanner adLoaded');\n    }}\n    onAdFailedToLoad={()=> {\n      this.setLog('AppSamuraiBanner onAdFailedToLoad');\n    }}\n    onAdOpened={()=> {\n      this.setLog('AppSamuraiBanner onAdOpened');\n    }}\n    onAdClosed={()=> {\n      this.setLog('AppSamuraiBanner onAdClosed');\n    }}\n    onAdLeftApplication={()=> {\n      this.setLog('AppSamuraiBanner onAdLeftApplication');\n    }}\n/>\n```\n\n`adUnitID`: AppSamurai Ads Ad Unit ID \n\n`gadAdUnitID`: Google AdMob Ad Unit ID \n\n`testDevices`: Array of test device IDs both for AppSamurai Ads and Google AdMob\n\n#### Supported Banner Sizes\nUse `adSize` property for banner size. Default size is banner (320x50)\n\n`banner`: 320x50, Standard Banner for Phones and Tablets\n\n`mediumRectangle`: 300x250, IAB Medium Rectangle for Phones and Tablets\n\n#### Callback Methods\n`onAdLoaded`: Called when an ad is received.\n\n`onAdFailedToLoad`: Called when an ad request failed.\n\n`onAdOpened`: Called when an ad opens an overlay that covers the screen.\n\n`onAdClosed`: Called when the user is about to return to the application after clicking on an ad.\n\n`onAdLeftApplication`: Called when a user click will open another app (such as the App Store), backgrounding the current app.\n\n### Interstitial\nImporting AppSamuraiInterstitial and AdNetwork\n``` js\nimport {\n    AdNetwork,\n    AppSamuraiInterstitial\n} from 'react-native-appsamurai-ads';\n```\nRequesting Ad\n``` js\nvar adUnitIDs = {\n  [AdNetwork.APPSAMURAI]: 'appsamurai-sample-android-interstitial-ad-id',\n  [AdNetwork.GOOGLE]: 'ca-app-pub-3940256099942544/1033173712',\n}\nvar testDeviceIDs = [\n  '<test-device-id-1>',\n  '<test-device-id-2>',\n  '<test-device-id-3>'\n]\n\nAppSamuraiInterstitial.setTestDevices(testDeviceIDs);\nAppSamuraiInterstitial.setAdUnitIDs(adUnitIDs);\nAppSamuraiInterstitial.addEventListener('adLoaded',\n  () => this.setLog('AppSamuraiInterstitial adLoaded');\n);\nAppSamuraiInterstitial.addEventListener('adFailedToLoad',\n  () => this.setLog('AppSamuraiInterstitial adFailedToLoad');\n);\nAppSamuraiInterstitial.addEventListener('adOpened',\n  () => this.setLog('AppSamuraiInterstitial adOpened');\n);\nAppSamuraiInterstitial.addEventListener('adClosed',\n  () => this.setLog('AppSamuraiInterstitial adClosed');\n);\nAppSamuraiInterstitial.addEventListener('adLeftApplication',\n  () => this.setLog('AppSamuraiInterstitial adLeftApplication');\n);\n\nAppSamuraiInterstitial.requestAd();\n```\n\nShowing ad when it is ready\n``` js\nAppSamuraiInterstitial.showAd();\n```\nAlso you can show ad with promise when it is ready\n``` js\nAppSamuraiInterstitial.requestAd()\n.then(() => \n    AppSamuraiInterstitial.showAd();\n)\n.catch(error => {\n        console.warn(\"An error occurred while requesting ad\");\n    }\n);\n```\n\n#### Event lists\n`adLoaded`: Called when an ad is received.\n\n`adFailedToLoad`: Called when an ad request failed.\n\n`adOpened`: Called when an ad opens an overlay that covers the screen.\n\n`adClosed`: Called when the user is about to return to the application after clicking on an ad.\n\n`adLeftApplication`: Called when a user click will open another app (such as the App Store), backgrounding the current app.\n\n#### Methods\n`setAdUnitIDs(adUnitIDs)`: Sets the AdUnit IDs for both AppSamurai Ads and Google AdMob\n\n`setTestDevices(testDeviceIDs)`: Sets the devices which are served test ads.\n\n`requestAd`: Requests an interstitial and returns a promise, which resolves on load and rejects on error.\n\n`showAd`: Shows an interstitial and returns a promise, which resolves when an ad is going to be shown, rejects when the ad is not ready to be shown.\n\n`isReady(callback)`: Calls callback with a boolean value whether the interstitial is ready to be shown.\n\n`addEventListener`: Adds an event to listener\n\n`removeEventListener`: Removes an event from listener\n\n`removeAllListeners`: Removes all events from listener\n\n### Rewarded Video\nImporting AppSamuraiRewarded and AdNetwork\n``` js\nimport {\n    AdNetwork,\n    AppSamuraiRewarded\n} from 'react-native-appsamurai-ads';\n```\n\nRequesting Ad\n``` js\nvar adUnitIDs = {\n  [AdNetwork.APPSAMURAI]: 'appsamurai-sample-android-rewardbasedvideo-ad-id',\n  [AdNetwork.GOOGLE]: 'ca-app-pub-3940256099942544/5224354917'\n};\n\nvar testDeviceIDs = [\n  '<test-device-id-1>',\n  '<test-device-id-2>',\n  '<test-device-id-3>'\n];\n\nAppSamuraiRewarded.setTestDevices(testDeviceIDs);\nAppSamuraiRewarded.setAdUnitIDs(adUnitIDs);\nAppSamuraiRewarded.addEventListener('adLoaded',\n  () => this.setLog('AppSamuraiRewarded adLoaded');\n);\nAppSamuraiRewarded.addEventListener('adFailedToLoad',\n  () => this.setLog('AppSamuraiRewarded adFailedToLoad');\n);\nAppSamuraiRewarded.addEventListener('adOpened',\n  () => this.setLog('AppSamuraiRewarded adOpened');\n);\nAppSamuraiRewarded.addEventListener('adClosed',\n  () => this.setLog('AppSamuraiRewarded adClosed');\n);\nAppSamuraiRewarded.addEventListener('adLeftApplication',\n  () => this.setLog('AppSamuraiRewarded adLeftApplication');\n);\nAppSamuraiRewarded.addEventListener('rewarded',\n  () => this.setLog('AppSamuraiRewarded rewarded');\n);\nAppSamuraiRewarded.addEventListener('videoStarted',\n  () => this.setLog('AppSamuraiRewarded videoStarted');\n);\nAppSamuraiRewarded.addEventListener('videoCompleted',\n  () => this.setLog('AppSamuraiRewarded videoCompleted');\n);\n\nAppSamuraiRewarded.requestAd();\n```\n\nShowing ad when it is ready\n``` js\nAppSamuraiRewarded.showAd();\n```\n\nAlso you can show ad with promise when it is ready\n``` js\nAppSamuraiRewarded.requestAd()\n.then(() => \n    AppSamuraiRewarded.showAd();\n)\n.catch(error => {\n        console.warn(\"An error occurred while requesting ad\");\n    }\n);\n```\n\n#### Event lists\n`adLoaded`: Called when an ad is received.\n\n`adFailedToLoad`: Called when an ad request failed.\n\n`adOpened`: Called when an ad opens an overlay that covers the screen.\n\n`adClosed`: Called when the user is about to return to the application after clicking on an ad.\n\n`adLeftApplication`: Called when a user click will open another app (such as the App Store), backgrounding the current app.\n\n`rewarded`: Called when the user eard reward.\n\n`videoStarted`: Called when the video is started.\n\n`videoCompleted`: Called when the video is completed.\n\n#### Methods\n`setAdUnitIDs(adUnitIDs)`: Sets the AdUnit IDs for both AppSamurai Ads and Google AdMob\n\n`setTestDevices(testDeviceIDs)`: Sets the devices which are served test ads.\n\n`requestAd`: Requests an interstitial and returns a promise, which resolves on load and rejects on error.\n\n`showAd`: Shows an interstitial and returns a promise, which resolves when an ad is going to be shown, rejects when the ad is not ready to be shown.\n\n`isReady(callback)`: Calls callback with a boolean value whether the interstitial is ready to be shown.\n\n`addEventListener`: Adds an event to listener\n\n`removeEventListener`: Removes an event from listener\n\n`removeAllListeners`: Removes all events from listener\n\n## Credits\n[`react-native-admob`](https://github.com/sbugert/react-native-admob) has been a great source of inspiration for this project.\n\n## License\nMIT\n","readmeFilename":"README.md"}