Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating cordova-vungle to most recent SDK #4

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Cordova plugin to use Vungle ad network.

We have tested with the following Vungle libraries

* Android 3.3.0
* iOS 3.0.10
* Android 4.0.2
* iOS 4.0.4

##Installing the plugin
To add this plugin just type:
Expand All @@ -18,7 +18,7 @@ To remove this plugin type:
###Android
On Android, plugin does most of the prerequisites automatically, arranges permissions, etc. in AndroidManifest.xml.

Note: We do NOT install google-playservices as a dependency anymore, Vungle does not require it, it's optional, check [Vungle documentation](https://github.com/Vungle/vungle-resources/blob/master/English/Android/current-release/android-dev-guide.md) for more details.
Note: We do NOT install google-playservices as a dependency anymore, Vungle does not require it, it's optional, check [Vungle documentation](https://support.vungle.com/hc/en-us/articles/204222794-Get-started-with-Vungle-Android-SDK) for more details.

#### Libs
You should only download and add Vungle libraries.
Expand Down Expand Up @@ -62,7 +62,7 @@ public class EachActivity extends android.app.Activity {
```

###iOS
On iOS, you should manually follow the instructions to add the frameworks to your project at this [link](https://github.com/Vungle/vungle-resources/blob/master/English/iOS/iOS-dev-guide.md). First 3 steps explain how to add the vungle framework and its dependencies.
On iOS, you should manually follow the instructions to add the frameworks to your project at this [link](https://support.vungle.com/hc/en-us/articles/204430550-Getting-Started-with-Vungle-iOS-SDK).


##Usage
Expand All @@ -81,15 +81,15 @@ Initializes the plugin. Must be called before calling any other function.
>> *vungleId*: string: Your Vungle app id.

>> *config*: object: Optional vungle config params as json object, see below for details. You do NOT need to supply all the params, defaults are used if a property is not supplied.
See vungle documentation [for android](https://github.com/Vungle/vungle-resources/blob/master/English/Android/3.2.x/android-advanced-settings.md#configuration-options) and [for ios](https://github.com/Vungle/vungle-resources/blob/master/English/iOS/iOS-advanced-settings.md#playad-options).
See vungle documentation [for android](https://support.vungle.com/hc/en-us/articles/204463100-Advanced-Settings-for-Vungle-Android-SDK) and [for ios](https://support.vungle.com/hc/en-us/articles/204463080-Advanced-Settings-for-Vungle-iOS-SDK).

>> *successCallback*: function

>> *failureCallback*: function: Called with failure reason string.

>####example

plugin.init('YOUR_VUNGLE_ID', {
Vungle.init('YOUR_VUNGLE_ID', {
/* These are all the properties we support, they are here for demonstration purposes only.
orientation: 0, // Android: 0 means Orientation.autoRotate, 1 means Orientation.matchVideo
// iOS: We recommend just sending 0, Vungle api is not unified for this param, same parameter mean and behave different for each platform!)
Expand Down Expand Up @@ -122,15 +122,15 @@ See vungle documentation [for android](https://github.com/Vungle/vungle-resource

>####parameters

>> *config*: object: Optional vungle config params as json object, see init for details
>> *config*: object: Optional vungle config params as json object to overide init config. Use null if you are happy with the config defined in your init.

>> *successCallback*: function: Called with a boolean for completion of video (to be used in incentivized ads)

>> *failureCallback*: function: Called with failure reason string.

>####example

plugin.playAd(config
Vungle.playAd(config
function(completed) { // success
console.log("Ad played");
}), failureCallback);
Expand All @@ -147,7 +147,7 @@ See vungle documentation [for android](https://github.com/Vungle/vungle-resource

>####example

plugin.isVideoAvailable(
Vungle.isVideoAvailable(
function(response) { // success
if(response)
console.log("We have an ad available.");
Expand Down
15 changes: 9 additions & 6 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<keywords>vungle,phonegap,cordova</keywords>

<js-module src="www/vungle.js" name="Vungle">
<merges target="CC" />
<merges target="Vungle" />
</js-module>

<!-- android -->
Expand All @@ -25,12 +25,15 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</config-file>
<config-file target="AndroidManifest.xml" parent="/*/application">
<activity
android:name="com.vungle.publisher.FullScreenAdActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<activity android:name="com.vungle.publisher.VideoFullScreenAdActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
</config-file>

<config-file target="AndroidManifest.xml" parent="/manifest/application">

<activity android:name="com.vungle.publisher.MraidFullScreenAdActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
</config-file>

<config-file target="res/xml/config.xml" parent="/*">
<feature name="CordovaVungle">
<param name="android-package" value="com.ccsoft.plugin.CordovaVungle" />
Expand Down
5 changes: 3 additions & 2 deletions src/android/CordovaVungle.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void onVideoView(boolean isCompletedView, int watchedMillis, int videoDur
// video).
if (isCompletedView) {
Log.i(TAG, "completed view");
callbackContext.success(1);
//callbackContext.success(1);
} else {
Log.i(TAG, "not completed view");
callbackContext.success(0);
Expand All @@ -86,9 +86,10 @@ public void onAdStart() {
}

@Override
public void onAdEnd(boolean wasCallToActionClicked) {
public void onAdEnd(boolean wasSuccessfulView, boolean wasCallToActionClicked) {
// Called when the user leaves the ad and control is returned to your application
Log.i(TAG, "ad ended");
callbackContext.success(1);
}

@Override
Expand Down
2 changes: 0 additions & 2 deletions src/ios/CordovaVungle.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ - (NSMutableDictionary*) processConfig: (NSDictionary*) config {
[result setObject:[config objectForKey:key] forKey:VunglePlayAdOptionKeyExtra7];
} else if([keyVal isEqualToString:@"extra8"]) {
[result setObject:[config objectForKey:key] forKey:VunglePlayAdOptionKeyExtra8];
} else if([keyVal isEqualToString:@"incentivizedCancelDialogBodyText"]) {
[VungleSDK sharedSDK].incentivizedAlertText = [config objectForKey:key];
} else if([keyVal isEqualToString:@"soundEnabled"]) {
BOOL muted = [[config objectForKey:key] isEqual: @(0)];
[[VungleSDK sharedSDK] setMuted:muted];
Expand Down
29 changes: 0 additions & 29 deletions www/vungle.d.ts

This file was deleted.

22 changes: 8 additions & 14 deletions www/vungle.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/// <reference path='vungle.d.ts'/>
var CC;
(function (CC) {
var Vungle = (function () {
function Vungle() {
}
Vungle.prototype.init = function (vungleid, config, successcb, errorcb) {

Vungle = {};

Vungle.init = function (vungleid, config, successcb, errorcb) {
window.cordova.exec(function () {
if (successcb)
successcb();
Expand All @@ -13,7 +10,7 @@ var CC;
errorcb(err);
}, "CordovaVungle", "init", [vungleid, config]);
};
Vungle.prototype.playAd = function (config, successcb, errorcb) {
Vungle.playAd = function (config, successcb, errorcb) {
window.cordova.exec(function (completed) {
if (successcb)
successcb(completed);
Expand All @@ -22,16 +19,13 @@ var CC;
errorcb(err);
}, "CordovaVungle", "playAd", [config]);
};
Vungle.prototype.isVideoAvailable = function (successcb, errorcb) {
Vungle.isVideoAvailable = function (successcb, errorcb) {
window.cordova.exec(function (s) {
successcb(s == 1 ? true : false);
}, function (err) {
if (errorcb)
errorcb(err);
}, "CordovaVungle", "isVideoAvailable", []);
};
return Vungle;
})();
CC.Vungle = Vungle;
})(CC || (CC = {}));
module.exports = CC;

module.exports = Vungle;
32 changes: 0 additions & 32 deletions www/vungle.ts

This file was deleted.