├── LICENSE
├── README.md
├── dependencies
└── android
│ ├── .classpath
│ ├── .project
│ ├── AndroidManifest.xml
│ ├── build.xml
│ ├── libs
│ └── unity-ads.jar
│ ├── proguard-project.txt
│ ├── project.properties
│ └── src
│ └── com
│ └── ipsilondev
│ ├── UnityAdsWrapper.java
│ └── UnityAdsWrapperListener.java
├── extension
└── unityads
│ └── UnityAds.hx
├── frameworks
├── UnityAds.bundle
│ ├── Info.plist
│ ├── audio_mute.png
│ ├── audio_mute@2x.png
│ ├── audio_on.png
│ ├── audio_on@2x.png
│ └── en.lproj
│ │ └── InfoPlist.strings
└── UnityAds.framework
│ ├── Headers
│ └── UnityAds.h
│ ├── Resources
│ ├── Info.plist
│ └── en.lproj
│ │ └── InfoPlist.strings
│ └── UnityAds
├── haxelib.json
├── include.xml
├── ndll
└── iPhone
│ ├── libopenflunityads.iphoneos-64.a
│ ├── libopenflunityads.iphoneos-v7.a
│ ├── libopenflunityads.iphonesim-64.a
│ └── libopenflunityads.iphonesim.a
├── project
├── Build.xml
├── common
│ ├── ExternalInterface.cpp
│ └── openflunityads.mm
├── include
│ └── OpenFLUnityAds.h
└── obj
│ ├── iphoneos-c11-64
│ ├── 57a9d1b2_ExternalInterface.o
│ ├── 57a9d1b2_openflunityads.o
│ ├── c0bbcb15_ExternalInterface.o
│ └── c0bbcb15_openflunityads.o
│ ├── iphoneos-c11-v7
│ ├── 3e59cb2d_ExternalInterface.o
│ ├── 3e59cb2d_openflunityads.o
│ ├── 9af90ac2_ExternalInterface.o
│ └── 9af90ac2_openflunityads.o
│ └── iphonesim-c11
│ ├── 1adaf564_ExternalInterface.o
│ ├── 1adaf564_openflunityads.o
│ ├── 30ebb521_ExternalInterface.o
│ ├── 30ebb521_openflunityads.o
│ ├── 64050daf_ExternalInterface.o
│ ├── 64050daf_openflunityads.o
│ ├── c53e14fa_ExternalInterface.o
│ └── c53e14fa_openflunityads.o
└── xcode-example.jpg
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Ipsilon Developments Inc
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # openfl-unityads
2 | UnityAds implementation for OpenFL/Haxe
3 |
4 | ### With love from:
5 |
6 | **[Ipsilon Developments Inc.](http://www.ipsilondev.com)** released under **MIT license**
7 |
8 | Like our **[Facebook](http://www.facebook.com/ipsilondev)** page to get news about our releases
9 |
10 | Or Follow us on **[Twitter](https://twitter.com/ipsilondev)**
11 |
12 | You can also contact us at **info [AT] ipsilondev.com**
13 |
14 | Known problems:
15 | ==========
16 |
17 | When compiling to Android, if you find an error like:
18 | `Can't read [/PATH/TO/unity-ads.jar] ( Can't process class [com/unity3d/ads/android/cache/UnityAdsCacheThread.class] (15360))`
19 |
20 | For now, you can disable Proguard, by commenting line 16 in [project.properties](https://github.com/ipsilondev/openfl-unityads/blob/master/dependencies/android/project.properties#L16). On next release, or the .jar will be replaced with the SDK source code, or this line will be commented forever.
21 |
22 | How to use
23 | ==========
24 |
25 | First of all, install the lib:
26 |
27 | ```bash
28 | haxelib install openfl-unityads
29 | ```
30 |
31 | Once this is done, you just need to add this to your project.xml
32 | ```xml
33 |
34 | ```
35 | Then, you must set up the event listeners, and then initialize.
36 |
37 | ```haxe
38 | import extension.unityads.UnityAds;
39 |
40 | UnityAds.onVideoStarted = function():Void {
41 | Lib.trace("onVideoStarted");
42 | };
43 | UnityAds.onVideoCompleted = function(key:String,reward:Bool):Void {
44 | Lib.trace("onVideoCompleted = "+key+" = "+reward);
45 | };
46 | UnityAds.onShow = function() {
47 | Lib.trace("onShow");
48 | };
49 | UnityAds.onHide = function() {
50 | Lib.trace("onHide");
51 | };
52 | UnityAds.onFetch = function(res:Bool):Void {
53 | Lib.trace("fetchResult = " + res);
54 | if (res) {
55 | var resShowAd:Bool = UnityAds.showAd("rewardedVideoZone");
56 | if (resShowAd) {
57 | Lib.trace("showing ad OK");
58 | }else {
59 | Lib.trace("notshowing ad");
60 | }
61 | }
62 | };
63 | UnityAds.init("YOUR_GAME_ID", true,true);
64 |
65 | //check statically if you are enable to show ads
66 | if(UnityAds.canShowAds()){
67 | Lib.trace("I can show ads !");
68 | }else{
69 | Lib.trace("I can NOT show ads !");
70 | }
71 | ```
72 |
73 | Important Notes
74 | ==========
75 |
76 | 
77 |
78 | 1) **Drag and Drop the UnityAds.bundle file inside the Resources folder in xCode !!! If you don't do this, your app will crash at showing the ad !**
79 |
80 | 2) This are all the available events that you can listen to. Is optional if you want to support all, or just a few. But be sure to catch up **onFetch event**, that say if the connection to UnityAds servers was successful and if is ready to show ads.
81 |
82 | 3) init() function, need GAMEID as mandatory parameter, and the other 2, are to enable test mode and debug mode. **be sure to disable both when you package your game !**
83 |
84 | 4) showAd() function requires of a zoneID to be passed, and optional, a rewardKey. you can get both from the UnityAds admin panel. i know that the documentation say's that zoneID is optional, but i discovered that at least in android, if you don't pass it, it never show an ad.
85 |
--------------------------------------------------------------------------------
/dependencies/android/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/dependencies/android/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | android
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/dependencies/android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/dependencies/android/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/dependencies/android/libs/unity-ads.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/dependencies/android/libs/unity-ads.jar
--------------------------------------------------------------------------------
/dependencies/android/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # Keep filenames and line numbers for stack traces
2 | -keepattributes SourceFile,LineNumberTable
3 |
4 | # Keep JavascriptInterface for WebView bridge
5 | -keepattributes JavascriptInterface
6 |
7 | # Keep all classes in Unity Ads package
8 | -keep class com.unity3d.ads.android.** {
9 | *;
10 | }
11 |
--------------------------------------------------------------------------------
/dependencies/android/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "build.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | android.library=true
11 |
12 | android.library.reference.1=../extension-api
13 |
14 | # Project target.
15 | target=android-::ANDROID_TARGET_SDK_VERSION::
16 | proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
17 |
--------------------------------------------------------------------------------
/dependencies/android/src/com/ipsilondev/UnityAdsWrapper.java:
--------------------------------------------------------------------------------
1 | package com.ipsilondev;
2 |
3 |
4 | import org.haxe.extension.Extension;
5 | import org.haxe.lime.HaxeObject;
6 | import com.unity3d.ads.android.UnityAds;
7 | import com.unity3d.ads.android.IUnityAdsListener;
8 | import com.ipsilondev.UnityAdsWrapperListener;
9 | import android.util.Log;
10 | import android.content.ActivityNotFoundException;
11 |
12 | public class UnityAdsWrapper extends Extension{
13 |
14 | public static HaxeObject cb;
15 | private static String gameId;
16 | private static UnityAdsWrapperListener listener;
17 | private static boolean testMode = false;
18 | private static boolean debugMode = false;
19 | private static boolean inited = false;
20 |
21 |
22 | //init UnityAds with the provided gameId and set up the haxe callback. set up test mode if is specified
23 | public static void init(HaxeObject callbackObject,String gId,boolean test,boolean debug){
24 | cb = callbackObject;
25 | gameId = gId;
26 | if(debug){
27 | UnityAds.setDebugMode(true);
28 | debugMode = debug;
29 | }
30 | if(test){
31 | UnityAds.setTestMode(true);
32 | testMode = test;
33 | }
34 | inited = true;
35 | listener = new UnityAdsWrapperListener();
36 | UnityAds.init(mainActivity, gameId, (IUnityAdsListener)listener);
37 | }
38 |
39 |
40 | public static boolean showAd(String zone,String rewardKey){
41 | if(rewardKey!="" && zone!=""){
42 | UnityAds.setZone(zone,rewardKey);
43 | }else if(zone!=""){
44 | UnityAds.setZone(zone);
45 | }
46 | if(UnityAds.canShow() && UnityAds.canShowAds()){
47 | mainActivity.runOnUiThread(new Runnable() {
48 | public void run() {
49 | UnityAds.show();
50 |
51 | }});
52 | return true;
53 | }else{
54 | return false;
55 | }
56 | }
57 |
58 | public static boolean canShowAd(){
59 | if(UnityAds.canShow() && UnityAds.canShowAds()){
60 | return true;
61 | }else{
62 | return false;
63 | }
64 | }
65 |
66 |
67 | /**
68 | * Called after {@link #onRestart}, or {@link #onPause}, for your activity
69 | * to start interacting with the user.
70 | */
71 | public void onResume () {
72 |
73 | super.onResume();
74 | if(inited){
75 | UnityAds.changeActivity(mainActivity);
76 | }
77 |
78 |
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/dependencies/android/src/com/ipsilondev/UnityAdsWrapperListener.java:
--------------------------------------------------------------------------------
1 | package com.ipsilondev;
2 |
3 |
4 | import org.haxe.extension.Extension;
5 | import org.haxe.lime.HaxeObject;
6 | import com.unity3d.ads.android.UnityAds;
7 | import com.unity3d.ads.android.IUnityAdsListener;
8 | import com.ipsilondev.UnityAdsWrapper;
9 | public class UnityAdsWrapperListener implements IUnityAdsListener{
10 | public void main(String[] args) {
11 | // TODO Auto-generated method stub
12 | }
13 |
14 | //after initied, this method is called if campaigns could be fetched
15 | public void onFetchCompleted(){
16 | UnityAdsWrapper.cb.call1("unityAdsOnFetch",true);
17 | }
18 | //after initied, this method is called if no campaigns could be fetched
19 | public void onFetchFailed(){
20 | UnityAdsWrapper.cb.call1("unityAdsOnFetch",false);
21 | }
22 |
23 | public void onVideoCompleted(String keyId,boolean rewarded){
24 | UnityAdsWrapper.cb.call2("unityAdsOnVideoCompleted",keyId,rewarded);
25 | }
26 |
27 | public void onVideoStarted(){
28 | UnityAdsWrapper.cb.call0("unityAdsOnVideoStarted");
29 | }
30 |
31 | public void onHide() {
32 | UnityAdsWrapper.cb.call0("unityAdsOnHide");
33 | }
34 |
35 | public void onShow() {
36 | UnityAdsWrapper.cb.call0("unityAdsOnShow");
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/extension/unityads/UnityAds.hx:
--------------------------------------------------------------------------------
1 | package extension.unityads;
2 |
3 |
4 | #if cpp
5 | import cpp.Lib;
6 | #elseif neko
7 | import neko.Lib;
8 | #end
9 |
10 | #if (android && openfl)
11 | import openfl.utils.JNI;
12 | #end
13 |
14 | class UnityAds {
15 | ///callbacks haxe
16 | public static var onFetch:Bool->Void = null;
17 | public static var onVideoCompleted:String->Bool->Void = null;
18 | public static var onVideoStarted:Void->Void = null;
19 | public static var onHide:Void->Void = null;
20 | public static var onShow:Void->Void = null;
21 |
22 | public static var instance:UnityAds = null;
23 | public static function init(gameId:String, test:Bool=false, debug:Bool=false):Void {
24 | libInit(getInstance(), gameId, test, debug);
25 | }
26 | public static function showAd(zone:String, rewardItemKey:String = ""):Bool {
27 | return libShowAd(zone, rewardItemKey);
28 | }
29 | public static function getInstance():UnityAds {
30 | if (instance == null) { instance = new UnityAds(); }
31 | return instance;
32 | }
33 | public static function canShowAds():Bool{
34 | return libCanShowAd();
35 | }
36 |
37 | ////java binings
38 | private static var libInit:UnityAds->String->Bool->Bool->Void =
39 | #if android
40 | JNI.createStaticMethod("com/ipsilondev/UnityAdsWrapper","init","(Lorg/haxe/lime/HaxeObject;Ljava/lang/String;ZZ)V");
41 | #elseif ios
42 | function(o:UnityAds, s:String, b1:Bool, b2:Bool):Void {
43 | onFetchiOSCallBack(getInstance().unityAdsOnFetch);
44 | onVideoCompletediOSCallBack(getInstance().unityAdsOnVideoCompleted);
45 | onVideoStartediOSCallBack(getInstance().unityAdsOnVideoStarted);
46 | onVideoHideiOSCallBack(getInstance().unityAdsOnHide);
47 | onVideoShowiOSCallBack(getInstance().unityAdsOnShow);
48 | iosInit(o,s,b1,b2);
49 |
50 | };
51 | #else
52 | function(o:UnityAds, s:String, b1:Bool, b2:Bool):Void {
53 |
54 | };
55 | #end
56 |
57 | private static var libShowAd:String->String->Bool =
58 | #if android
59 | JNI.createStaticMethod("com/ipsilondev/UnityAdsWrapper","showAd","(Ljava/lang/String;Ljava/lang/String;)Z");
60 | #elseif ios
61 | Lib.load("openflunityads","openflunityads_showAd",2);
62 | #else
63 | function(s:String="", s2:String=""):Bool {
64 | return true;
65 | };
66 | #end
67 |
68 | private static var libCanShowAd:Void->Bool =
69 | #if android
70 | JNI.createStaticMethod("com/ipsilondev/UnityAdsWrapper","canShowAd","()Z");
71 | #elseif ios
72 | Lib.load("openflunityads","openflunityads_canShowAd",0);
73 | #else
74 | function():Bool {
75 | return false;
76 | };
77 | #end
78 |
79 | #if ios
80 | //init function only for ios
81 | private static var iosInit = Lib.load("openflunityads","openflunityads_init",4);
82 | #end
83 |
84 | //register event handlers for ios
85 | #if ios
86 | private static var onFetchiOSCallBack = Lib.load("openflunityads","openflunityads_setOnFetchCB",1);
87 | private static var onVideoCompletediOSCallBack = Lib.load("openflunityads","openflunityads_setOnVideoCompletedCB",1);
88 | private static var onVideoStartediOSCallBack = Lib.load("openflunityads","openflunityads_setOnVideoStartedCB",1);
89 | private static var onVideoHideiOSCallBack = Lib.load("openflunityads","openflunityads_setOnVideoHideCB",1);
90 | private static var onVideoShowiOSCallBack = Lib.load("openflunityads","openflunityads_setOnVideoShowCB",1);
91 | #end
92 |
93 | //event handlers
94 | public function new() {
95 |
96 | }
97 |
98 | public function unityAdsOnFetch(result:Bool):Void {
99 | if (onFetch != null) {
100 | onFetch(result);
101 | }
102 | }
103 |
104 | public function unityAdsOnVideoCompleted(keyId:String, rewarded:Bool):Void {
105 | if (onVideoCompleted != null) {
106 | onVideoCompleted(keyId, rewarded);
107 | }
108 |
109 | }
110 |
111 | public function unityAdsOnVideoStarted():Void {
112 | if (onVideoStarted != null) {
113 | onVideoStarted();
114 | }
115 | }
116 | public function unityAdsOnHide():Void {
117 | if (onHide != null) {
118 | onHide();
119 | }
120 | }
121 |
122 | public function unityAdsOnShow():Void {
123 | if (onShow != null) {
124 | onShow();
125 | }
126 | }
127 |
128 |
129 |
130 | }
131 |
--------------------------------------------------------------------------------
/frameworks/UnityAds.bundle/Info.plist:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/frameworks/UnityAds.bundle/Info.plist
--------------------------------------------------------------------------------
/frameworks/UnityAds.bundle/audio_mute.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/frameworks/UnityAds.bundle/audio_mute.png
--------------------------------------------------------------------------------
/frameworks/UnityAds.bundle/audio_mute@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/frameworks/UnityAds.bundle/audio_mute@2x.png
--------------------------------------------------------------------------------
/frameworks/UnityAds.bundle/audio_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/frameworks/UnityAds.bundle/audio_on.png
--------------------------------------------------------------------------------
/frameworks/UnityAds.bundle/audio_on@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/frameworks/UnityAds.bundle/audio_on@2x.png
--------------------------------------------------------------------------------
/frameworks/UnityAds.bundle/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/frameworks/UnityAds.bundle/en.lproj/InfoPlist.strings
--------------------------------------------------------------------------------
/frameworks/UnityAds.framework/Headers/UnityAds.h:
--------------------------------------------------------------------------------
1 | //
2 | // UnityAds.h
3 | // Copyright (c) 2012 Unity Technologies. All rights reserved.
4 | //
5 |
6 | #import
7 | #import
8 |
9 | #define UALOG_LOG(levelName, fmt, ...) if ([[UnityAds sharedInstance] isDebugMode]) NSLog((@"%@ [T:0x%x %@] %s:%d " fmt), levelName, (unsigned int)[NSThread currentThread], ([[NSThread currentThread] isMainThread] ? @"M" : @"S"), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
10 |
11 | #define UALOG_ERROR(fmt, ...) UALOG_LOG(@"ERROR", fmt, ##__VA_ARGS__)
12 |
13 | #define UALOG_DEBUG(fmt, ...) UALOG_LOG(@"DEBUG", fmt, ##__VA_ARGS__)
14 | #define UAAssert(condition) do { if ([[UnityAds sharedInstance] isDebugMode] && !(condition)) { UALOG_ERROR(@"Expected condition '%s' to be true.", #condition); abort(); } } while(0)
15 | #define UAAssertV(condition, value) do { if ([[UnityAds sharedInstance] isDebugMode] && !(condition)) { UALOG_ERROR(@"Expected condition '%s' to be true.", #condition); abort(); } } while(0)
16 |
17 | extern NSString * const kUnityAdsRewardItemPictureKey;
18 | extern NSString * const kUnityAdsRewardItemNameKey;
19 |
20 | extern NSString * const kUnityAdsOptionNoOfferscreenKey;
21 | extern NSString * const kUnityAdsOptionOpenAnimatedKey;
22 | extern NSString * const kUnityAdsOptionGamerSIDKey;
23 | extern NSString * const kUnityAdsOptionMuteVideoSounds;
24 | extern NSString * const kUnityAdsOptionVideoUsesDeviceOrientation;
25 |
26 | @class UnityAds;
27 | @class SKStoreProductViewController;
28 |
29 | @protocol UnityAdsDelegate
30 |
31 | @required
32 | - (void)unityAdsVideoCompleted:(NSString *)rewardItemKey skipped:(BOOL)skipped;
33 |
34 | @optional
35 | - (void)unityAdsWillShow;
36 | - (void)unityAdsDidShow;
37 | - (void)unityAdsWillHide;
38 | - (void)unityAdsDidHide;
39 | - (void)unityAdsWillLeaveApplication;
40 | - (void)unityAdsVideoStarted;
41 | - (void)unityAdsFetchCompleted;
42 | - (void)unityAdsFetchFailed;
43 | @end
44 |
45 | @interface UnityAds : NSObject
46 |
47 | @property (nonatomic, weak) id delegate;
48 |
49 | + (UnityAds *)sharedInstance;
50 | + (BOOL)isSupported;
51 | + (NSString *)getSDKVersion;
52 |
53 | - (void)setTestDeveloperId:(NSString *)developerId;
54 | - (void)setTestOptionsId:(NSString *)optionsId;
55 | - (void)setDebugMode:(BOOL)debugMode;
56 | - (void)setTestMode:(BOOL)testModeEnabled;
57 | - (void)enableUnityDeveloperInternalTestMode;
58 | - (void)setCampaignDataURL:(NSString *)campaignDataUrl;
59 | - (void)setUnityVersion:(NSString *)unityVersion;
60 |
61 | - (BOOL)isDebugMode;
62 | - (BOOL)startWithGameId:(NSString *)gameId andViewController:(UIViewController *)viewController;
63 | - (BOOL)startWithGameId:(NSString *)gameId;
64 | - (BOOL)setViewController:(UIViewController *)viewController;
65 | - (BOOL)canShowAds;
66 | - (BOOL)canShow;
67 | - (BOOL)canShowZone:(NSString *)zoneId;
68 | - (BOOL)setZone:(NSString *)zoneId;
69 | - (BOOL)setZone:(NSString *)zoneId withRewardItem:(NSString *)rewardItemKey;
70 | - (NSString *)getZone;
71 | - (BOOL)show:(NSDictionary *)options;
72 | - (BOOL)show;
73 | - (BOOL)hide;
74 | - (void)stopAll;
75 | - (BOOL)hasMultipleRewardItems;
76 | - (NSArray *)getRewardItemKeys;
77 | - (NSString *)getDefaultRewardItemKey;
78 | - (NSString *)getCurrentRewardItemKey;
79 | - (BOOL)setRewardItemKey:(NSString *)rewardItemKey;
80 | - (void)setDefaultRewardItemAsRewardItem;
81 | - (NSDictionary *)getRewardItemDetailsWithKey:(NSString *)rewardItemKey;
82 | @end
83 |
--------------------------------------------------------------------------------
/frameworks/UnityAds.framework/Resources/Info.plist:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/frameworks/UnityAds.framework/Resources/Info.plist
--------------------------------------------------------------------------------
/frameworks/UnityAds.framework/Resources/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/frameworks/UnityAds.framework/Resources/en.lproj/InfoPlist.strings
--------------------------------------------------------------------------------
/frameworks/UnityAds.framework/UnityAds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/frameworks/UnityAds.framework/UnityAds
--------------------------------------------------------------------------------
/haxelib.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "openfl-unityads",
3 | "url": "https://github.com/ipsilondev/openfl-unityads",
4 | "license": "MIT",
5 | "tags": ["cross","openfl","ads","unity"],
6 | "description": "UnityAds Implementation for OpenFL/Haxe",
7 | "version": "1.0.6",
8 | "releasenote": "Updating SDK to 1.5.6",
9 | "contributors": ["ipsilondev"],
10 | "dependencies": {
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/include.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/ndll/iPhone/libopenflunityads.iphoneos-64.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/ndll/iPhone/libopenflunityads.iphoneos-64.a
--------------------------------------------------------------------------------
/ndll/iPhone/libopenflunityads.iphoneos-v7.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/ndll/iPhone/libopenflunityads.iphoneos-v7.a
--------------------------------------------------------------------------------
/ndll/iPhone/libopenflunityads.iphonesim-64.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/ndll/iPhone/libopenflunityads.iphonesim-64.a
--------------------------------------------------------------------------------
/ndll/iPhone/libopenflunityads.iphonesim.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/ndll/iPhone/libopenflunityads.iphonesim.a
--------------------------------------------------------------------------------
/project/Build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/project/common/ExternalInterface.cpp:
--------------------------------------------------------------------------------
1 | #ifndef STATIC_LINK
2 | #define IMPLEMENT_API
3 | #endif
4 |
5 | #if defined(HX_WINDOWS) || defined(HX_MACOS) || defined(HX_LINUX)
6 | #define NEKO_COMPATIBLE
7 | #endif
8 |
9 |
10 | #include
11 | #include "OpenFLUnityAds.h"
12 |
13 |
14 | using namespace openflunityads;
15 |
16 |
17 |
18 | static void openflunityads_init (value cb, value gameId, value testmode, value debugmode) {
19 |
20 | InitUnityAds(cb,val_string(gameId),val_bool(testmode),val_bool(debugmode));
21 |
22 | }
23 | DEFINE_PRIM (openflunityads_init, 4);
24 |
25 | static value openflunityads_showAd (value zone, value rewardKey) {
26 |
27 | return alloc_bool(show(val_string(zone),val_string(rewardKey)));
28 | }
29 | DEFINE_PRIM (openflunityads_showAd, 2);
30 |
31 | static void openflunityads_setOnFetchCB (value f) {
32 |
33 | setOnFetchCB(f);
34 |
35 | }
36 | DEFINE_PRIM (openflunityads_setOnFetchCB, 1);
37 |
38 | static void openflunityads_setOnVideoCompletedCB (value f) {
39 |
40 | setOnVideoCompletedCB(f);
41 |
42 | }
43 | DEFINE_PRIM (openflunityads_setOnVideoCompletedCB, 1);
44 |
45 | static void openflunityads_setOnVideoStartedCB (value f) {
46 |
47 | setOnVideoStartedCB(f);
48 |
49 | }
50 | DEFINE_PRIM (openflunityads_setOnVideoStartedCB, 1);
51 |
52 | static void openflunityads_setOnVideoHideCB (value f) {
53 |
54 | setOnVideoHideCB(f);
55 |
56 | }
57 | DEFINE_PRIM (openflunityads_setOnVideoHideCB, 1);
58 |
59 | static void openflunityads_setOnVideoShowCB (value f) {
60 |
61 | setOnVideoShowCB(f);
62 |
63 | }
64 | DEFINE_PRIM (openflunityads_setOnVideoShowCB, 1);
65 |
66 | static value openflunityads_canShowAd () {
67 |
68 | return alloc_bool(canShowAds());
69 | }
70 | DEFINE_PRIM (openflunityads_canShowAd, 0);
71 |
72 |
73 | extern "C" void openflunityads_main () {
74 |
75 | val_int(0); // Fix Neko init
76 |
77 | }
78 | DEFINE_ENTRY_POINT (openflunityads_main);
79 |
80 |
81 |
82 | extern "C" int openflunityads_register_prims () { return 0; }
83 |
--------------------------------------------------------------------------------
/project/common/openflunityads.mm:
--------------------------------------------------------------------------------
1 | #include
2 | #include "OpenFLUnityAds.h"
3 | #import
4 | #import
5 | #import
6 |
7 | extern "C" {
8 | NSString* UnityAdsCreateNSString (const char* string) {
9 | return string ? [NSString stringWithUTF8String: string] : [NSString stringWithUTF8String: ""];
10 | }
11 | }
12 |
13 | @interface UnityAdsWrapper : NSObject {
14 | }
15 |
16 | - (void)initUnityAds:(NSString*)gameId testModeOn:(BOOL)testMode debugModeOn:(BOOL)debugMode;
17 | @end
18 |
19 | @implementation UnityAdsWrapper
20 |
21 | - (void)initUnityAds:(NSString*)gameId testModeOn:(BOOL)testMode debugModeOn:(BOOL)debugMode{
22 | [[UnityAds sharedInstance] setDelegate:self];
23 | [[UnityAds sharedInstance] setTestMode:testMode];
24 | [[UnityAds sharedInstance] setDebugMode:debugMode];
25 |
26 | [[UnityAds sharedInstance] startWithGameId:gameId andViewController:[[[UIApplication sharedApplication] keyWindow] rootViewController]];
27 | }
28 |
29 | - (void)unityAdsFetchCompleted {
30 | NSLog(@"unityAdsFetchCompleted");
31 | openflunityads::onFetch(true);
32 | }
33 |
34 | - (void)unityAdsFetchFailed {
35 | openflunityads::onFetch(false);
36 | }
37 |
38 | - (void)unityAdsDidShow {
39 | NSLog(@"unityAdsDidShow");
40 | openflunityads::onVideoShow();
41 | }
42 |
43 | - (void)unityAdsDidHide {
44 | NSLog(@"unityAdsDidHide");
45 | openflunityads::onVideoHide();
46 | }
47 |
48 | - (void)unityAdsVideoStarted {
49 | NSLog(@"unityAdsVideoStarted");
50 | openflunityads::onVideoStarted();
51 | }
52 |
53 | - (void)unityAdsVideoCompleted:(NSString *)rewardItemKey skipped:(BOOL)skipped {
54 | NSLog(@"unityAdsVideoCompleted:rewardItemKey:skipped -- key: %@ -- skipped: %@", rewardItemKey, skipped ? @"true" : @"false");
55 | openflunityads::onVideoCompleted([rewardItemKey UTF8String],skipped);
56 | }
57 |
58 | @end
59 |
60 | namespace openflunityads {
61 |
62 | value *onFetchCB = NULL;
63 | value *onVideoCompletedCB = NULL;
64 | value *onVideoStartedCB = NULL;
65 | value *onVideoHideCB = NULL;
66 | value *onVideoShowCB = NULL;
67 | void InitUnityAds(value cb, const char *gameId, bool testMode, bool debugMode) {
68 | [[UnityAdsWrapper alloc] initUnityAds:UnityAdsCreateNSString(gameId) testModeOn:testMode debugModeOn:debugMode];
69 |
70 | }
71 |
72 | bool show (const char * rawZoneId, const char * rawRewardItemKey){
73 | NSString * zoneId = UnityAdsCreateNSString(rawZoneId);
74 | NSString * rewardItemKey = UnityAdsCreateNSString(rawRewardItemKey);
75 |
76 | if ([[UnityAds sharedInstance] canShowAds] && [[UnityAds sharedInstance] canShow]) {
77 | if([rewardItemKey length] > 0) {
78 | [[UnityAds sharedInstance] setZone:zoneId withRewardItem:rewardItemKey];
79 | } else {
80 | [[UnityAds sharedInstance] setZone:zoneId];
81 | }
82 | [[UnityAds sharedInstance] show];
83 | return true;
84 | }
85 | return false;
86 |
87 | }
88 |
89 | void onFetch(bool result){
90 | val_call1(*onFetchCB,alloc_bool(result));
91 | }
92 |
93 | void onVideoCompleted(const char * keyId, bool rewarded){
94 | val_call2(*onVideoCompletedCB,alloc_bool(keyId),alloc_bool(rewarded));
95 | }
96 |
97 | void onVideoStarted(){
98 | val_call0(*onVideoStartedCB);
99 | }
100 |
101 | void onVideoHide(){
102 | val_call0(*onVideoHideCB);
103 | }
104 |
105 | void onVideoShow(){
106 | val_call0(*onVideoShowCB);
107 | }
108 |
109 | void setOnFetchCB(value f){
110 | val_check_function(f,1);
111 | onFetchCB = alloc_root();
112 | *onFetchCB = f;
113 | }
114 | void setOnVideoCompletedCB(value f){
115 | val_check_function(f,2);
116 | onVideoCompletedCB = alloc_root();
117 | *onVideoCompletedCB = f;
118 | }
119 | void setOnVideoStartedCB(value f){
120 | val_check_function(f,0);
121 | onVideoStartedCB = alloc_root();
122 | *onVideoStartedCB = f;
123 | }
124 | void setOnVideoHideCB(value f){
125 | val_check_function(f,0);
126 | onVideoHideCB = alloc_root();
127 | *onVideoHideCB = f;
128 | }
129 | void setOnVideoShowCB(value f){
130 | val_check_function(f,0);
131 | onVideoShowCB = alloc_root();
132 | *onVideoShowCB = f;
133 | }
134 |
135 |
136 | bool canShowAds () {
137 | if([[UnityAds sharedInstance] canShowAds] && [[UnityAds sharedInstance] canShow]){
138 | return true;
139 | }else{
140 | return false;
141 | }
142 | }
143 |
144 |
145 | }
146 |
--------------------------------------------------------------------------------
/project/include/OpenFLUnityAds.h:
--------------------------------------------------------------------------------
1 | #ifndef OPENFLUNITYADS_H
2 | #define OPENFLUNITYADS_H
3 |
4 |
5 | namespace openflunityads {
6 |
7 |
8 | void InitUnityAds(value cb, const char *gameId, bool testmode, bool debugmode);
9 | bool show (const char * rawZoneId, const char * rawRewardItemKey);
10 | void onFetch(bool result);
11 | void onVideoCompleted(const char * keyId, bool rewarded);
12 | void onVideoStarted();
13 | void onVideoHide();
14 | void onVideoShow();
15 | void setOnFetchCB(value f);
16 | void setOnVideoCompletedCB(value f);
17 | void setOnVideoStartedCB(value f);
18 | void setOnVideoHideCB(value f);
19 | void setOnVideoShowCB(value f);
20 | bool canShowAds();
21 |
22 | }
23 |
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/project/obj/iphoneos-c11-64/57a9d1b2_ExternalInterface.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/project/obj/iphoneos-c11-64/57a9d1b2_ExternalInterface.o
--------------------------------------------------------------------------------
/project/obj/iphoneos-c11-64/57a9d1b2_openflunityads.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/project/obj/iphoneos-c11-64/57a9d1b2_openflunityads.o
--------------------------------------------------------------------------------
/project/obj/iphoneos-c11-64/c0bbcb15_ExternalInterface.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/project/obj/iphoneos-c11-64/c0bbcb15_ExternalInterface.o
--------------------------------------------------------------------------------
/project/obj/iphoneos-c11-64/c0bbcb15_openflunityads.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/project/obj/iphoneos-c11-64/c0bbcb15_openflunityads.o
--------------------------------------------------------------------------------
/project/obj/iphoneos-c11-v7/3e59cb2d_ExternalInterface.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/project/obj/iphoneos-c11-v7/3e59cb2d_ExternalInterface.o
--------------------------------------------------------------------------------
/project/obj/iphoneos-c11-v7/3e59cb2d_openflunityads.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/project/obj/iphoneos-c11-v7/3e59cb2d_openflunityads.o
--------------------------------------------------------------------------------
/project/obj/iphoneos-c11-v7/9af90ac2_ExternalInterface.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/project/obj/iphoneos-c11-v7/9af90ac2_ExternalInterface.o
--------------------------------------------------------------------------------
/project/obj/iphoneos-c11-v7/9af90ac2_openflunityads.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/project/obj/iphoneos-c11-v7/9af90ac2_openflunityads.o
--------------------------------------------------------------------------------
/project/obj/iphonesim-c11/1adaf564_ExternalInterface.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/project/obj/iphonesim-c11/1adaf564_ExternalInterface.o
--------------------------------------------------------------------------------
/project/obj/iphonesim-c11/1adaf564_openflunityads.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/project/obj/iphonesim-c11/1adaf564_openflunityads.o
--------------------------------------------------------------------------------
/project/obj/iphonesim-c11/30ebb521_ExternalInterface.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/project/obj/iphonesim-c11/30ebb521_ExternalInterface.o
--------------------------------------------------------------------------------
/project/obj/iphonesim-c11/30ebb521_openflunityads.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/project/obj/iphonesim-c11/30ebb521_openflunityads.o
--------------------------------------------------------------------------------
/project/obj/iphonesim-c11/64050daf_ExternalInterface.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/project/obj/iphonesim-c11/64050daf_ExternalInterface.o
--------------------------------------------------------------------------------
/project/obj/iphonesim-c11/64050daf_openflunityads.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/project/obj/iphonesim-c11/64050daf_openflunityads.o
--------------------------------------------------------------------------------
/project/obj/iphonesim-c11/c53e14fa_ExternalInterface.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/project/obj/iphonesim-c11/c53e14fa_ExternalInterface.o
--------------------------------------------------------------------------------
/project/obj/iphonesim-c11/c53e14fa_openflunityads.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/project/obj/iphonesim-c11/c53e14fa_openflunityads.o
--------------------------------------------------------------------------------
/xcode-example.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipsilondev/openfl-unityads/20b7c45abaa3d9c07fcc08736216a93ab5fbe2bb/xcode-example.jpg
--------------------------------------------------------------------------------