diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..e13d8ac5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 RedPill + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 2f5c4ac7..a1985104 100644 --- a/README.md +++ b/README.md @@ -329,6 +329,22 @@ IronSourceRewardedVideo.isRewardedVideoAvailable().then((available) => { }); ``` +### IronSourceRewardedVideo.isRewardedVideoPlacementCapped(PlacementName) +Check if a reward video placement is capped. +Take a string corresponding to the placement desired and return a boolean. +If a wrong placement name is given, the function is applied to the default placement configured. + +```javascript + async isRewardedVideoPlacementCapped(placementName) { + try { + return IronSourceRewardedVideo.isRewardedVideoPlacementCapped(placementName); + } + catch (e) { + console.error('isRewardedVideoPlacementCapped failed: ', e); + } + } +``` + ## Events ### Banner events diff --git a/RNIronSource.podspec b/RNIronSource.podspec index 66778075..067b0a74 100644 --- a/RNIronSource.podspec +++ b/RNIronSource.podspec @@ -75,4 +75,4 @@ Pod::Spec.new do |s| s.static_framework = false end -end +end \ No newline at end of file diff --git a/RNIronSourceRewardedVideo.js b/RNIronSourceRewardedVideo.js index 0b2f71ed..a0ec1d92 100644 --- a/RNIronSourceRewardedVideo.js +++ b/RNIronSourceRewardedVideo.js @@ -64,6 +64,7 @@ module.exports = { ...RNIronSourceRewardedVideo, initializeRewardedVideo: () => RNIronSourceRewardedVideo.initializeRewardedVideo(), showRewardedVideo: (placementName) => RNIronSourceRewardedVideo.showRewardedVideo(placementName), + isRewardedVideoPlacementCapped: (placementName) => RNIronSourceRewardedVideo.isRewardedVideoPlacementCapped(placementName), isRewardedVideoAvailable: () => RNIronSourceRewardedVideo.isRewardedVideoAvailable(), setDynamicUserId: (userId) => RNIronSourceRewardedVideo.setDynamicUserId(userId), addEventListener, diff --git a/android/src/main/java/co/squaretwo/ironsource/RNIronSourceRewardedVideoModule.java b/android/src/main/java/co/squaretwo/ironsource/RNIronSourceRewardedVideoModule.java index fddaa2fb..27f338e2 100644 --- a/android/src/main/java/co/squaretwo/ironsource/RNIronSourceRewardedVideoModule.java +++ b/android/src/main/java/co/squaretwo/ironsource/RNIronSourceRewardedVideoModule.java @@ -128,6 +128,18 @@ public void run() { }); } + @ReactMethod + public void isRewardedVideoPlacementCapped(final String placementName, Promise promise) { + try { + Log.d(TAG, "isRewardedVideoPlacementCapped() called!!"); + promise.resolve(IronSource.isRewardedVideoPlacementCapped(placementName)); + } + catch (Exception e) { + Log.d(TAG, "isRewardedVideoPlacementCapped error %s", e); + promise.reject("isRewardedVideoPlacementCapped, Error, " + e); + } + } + @ReactMethod public void isRewardedVideoAvailable(Promise promise) { try { diff --git a/ios/RNIronSource.m b/ios/RNIronSource.m index ccc861cf..eeb26d64 100644 --- a/ios/RNIronSource.m +++ b/ios/RNIronSource.m @@ -20,7 +20,7 @@ - (dispatch_queue_t)methodQueue { NSLog(@"initializeIronSource called!! with key %@ and user id %@", appId, userId); [IronSource setUserId:userId]; - [IronSource initWithAppKey:appId]; + [IronSource initWithAppKey:appId adUnits:@[IS_REWARDED_VIDEO]]; BOOL validateIntegration = [RCTConvert BOOL:options[@"validateIntegration"]]; if (validateIntegration) { diff --git a/ios/RNIronSourceRewardedVideo.m b/ios/RNIronSourceRewardedVideo.m index c3f72bfc..9562530a 100644 --- a/ios/RNIronSourceRewardedVideo.m +++ b/ios/RNIronSourceRewardedVideo.m @@ -64,6 +64,17 @@ - (dispatch_queue_t)methodQueue } } +RCT_EXPORT_METHOD(isRewardedVideoPlacementCapped:(NSString*)placementName : (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) +{ + @try { + resolve(@([IronSource isRewardedVideoCappedForPlacement:@"Placement"])); + } + @catch (NSException *exception) { + NSLog(@"isRewardedVideoCappedForPlacement, Error, %@", exception.reason); + reject(@"isRewardedVideoCappedForPlacement, Error, %@", exception.reason, nil); + } +} + RCT_EXPORT_METHOD(isRewardedVideoAvailable:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) { @try { diff --git a/package-lock.json b/package-lock.json index 63187b9c..7b0156e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@wowmaking/react-native-iron-source", - "version": "3.3.6", + "version": "3.3.11", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 398f4e43..0d966170 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@wowmaking/react-native-iron-source", - "version": "3.3.6", + "version": "3.3.11", "description": "React Native package to interface the ironSource SDK. https://ironsrc.com", "main": "index.js", "scripts": {