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

UnityADS SDK 3.1 #6

Merged
merged 11 commits into from
Jun 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
67 changes: 66 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ or point to the ZIP file of a [specific release](https://github.com/AGulev/DefVi

See the [example folder](https://github.com/AGulev/DefVideoAds/tree/master/example) for understand how to use extension. Especially [ui.gui_script](https://github.com/AGulev/DefVideoAds/blob/master/example/ui.gui_script) file.

![Example screenshot](https://user-images.githubusercontent.com/2209596/40448649-cf08e002-5ede-11e8-9681-c20d17c0512a.jpg)
![Example screenshot](https://user-images.githubusercontent.com/2209596/60367270-1b40ab80-99ee-11e9-87e8-7dc9f8108615.gif)


## LUA Api
Expand Down Expand Up @@ -107,6 +107,36 @@ unityads.getVersion() -- Returns the Unity Ads SDK version as a string.
unityads.show() -- show default ad
unityads.show("rewardedVideo") -- show rewardedVideo
```
#### unityads.loadBanner(placementId)
```lua
unityads.loadBanner("banner") -- load banner
```
#### unityads.unloadBanner()
```lua
unityads.unloadBanner() -- unload banner
```
#### unityads.showBanner()
```lua
unityads.showBanner() -- show loaded banner
```
#### unityads.hideBanner()
```lua
unityads.hideBanner() -- hide banner
```
#### unityads.setBannerPosition(position)
```lua
unityads.setBannerPosition(position) -- set position of the banner
-- default value is unityads.BANNER_POSITION_TOP_CENTER
--possible positions:
unityads.BANNER_POSITION_TOP_LEFT
unityads.BANNER_POSITION_TOP_CENTER
unityads.BANNER_POSITION_TOP_RIGHT
unityads.BANNER_POSITION_BOTTOM_LEFT
unityads.BANNER_POSITION_BOTTOM_CENTER
unityads.BANNER_POSITION_BOTTOM_RIGHT
unityads.BANNER_POSITION_CENTER
unityads.BANNER_POSITION_NONE
```

### Constants
```lua
Expand All @@ -121,6 +151,7 @@ unityads.TYPE_IS_READY
unityads.TYPE_DID_START
unityads.TYPE_DID_ERROR
unityads.TYPE_DID_FINISH
unityads.TYPE_BANNER
```
##### unityads.TYPE_IS_READY
```lua
Expand Down Expand Up @@ -154,6 +185,18 @@ local function defunityads_callback(self, msg_type, message)
end
end
```
##### unityads.TYPE_BANNER
```lua
local function defunityads_callback(self, msg_type, message)
if msg_type == unityads.TYPE_BANNER then
if message.event == BANNER_EVENT_DID_ERROR then
pprint(message) -- message = {event = BANNER_EVENT_DID_ERROR, error = "string"}
else
pprint(message) -- message = {event = BANNER_EVENT_*, placementId = "string"}
end
end
end
```
#### Error types
[Original doc about error types](https://github.com/Unity-Technologies/unity-ads-ios/wiki/sdk_ios_api_errors)
```lua
Expand Down Expand Up @@ -197,5 +240,27 @@ local function defunityads_callback(self, msg_type, message)
end
end
```
#### Banner events
```lua
--possible banner events:
unityads.BANNER_EVENT_DID_LOAD
unityads.BANNER_EVENT_DID_UNLOAD
unityads.BANNER_EVENT_DID_SHOW
unityads.BANNER_EVENT_DID_HIDE
unityads.BANNER_EVENT_DID_CLICK
unityads.BANNER_EVENT_DID_ERROR
```
```lua
local function defunityads_callback(self, msg_type, message)
if msg_type == unityads.TYPE_BANNER then
if message.event == unityads.BANNER_EVENT_DID_LOAD then
...
elseif message.event == unityads.BANNER_EVENT_DID_UNLOAD then
...
end
end
```

---

If you have any issues, questions or suggestions please [create an issue](https://github.com/AGulev/DefVideoAds/issues) or contact me: me@agulev.com
85 changes: 84 additions & 1 deletion defunityads/api/DefUnityAds.script_api
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,39 @@
- name: placementId
type: string

#*****************************************************************************************************

- name: loadBanner
type: function

parameters:
- name: placementId
type: string

#*****************************************************************************************************

- name: unloadBanner
type: function

#*****************************************************************************************************

- name: showBanner
type: function

#*****************************************************************************************************

- name: hideBanner
type: function

#*****************************************************************************************************

- name: setBannerPosition
type: function

parameters:
- name: position
type: number

#*****************************************************************************************************

- name: TYPE_IS_READY
Expand All @@ -107,6 +140,9 @@
- name: TYPE_DID_FINISH
type: number

- name: TYPE_BANNER
type: number


#*****************************************************************************************************

Expand Down Expand Up @@ -141,4 +177,51 @@
type: number


#*****************************************************************************************************
#*****************************************************************************************************

- name: BANNER_POSITION_TOP_LEFT
type: number

- name: BANNER_POSITION_TOP_CENTER
type: number

- name: BANNER_POSITION_TOP_RIGHT
type: number

- name: BANNER_POSITION_BOTTOM_LEFT
type: number

- name: BANNER_POSITION_BOTTOM_CENTER
type: number

- name: BANNER_POSITION_BOTTOM_RIGHT
type: number

- name: BANNER_POSITION_CENTER
type: number

- name: BANNER_POSITION_NONE
type: number

#*****************************************************************************************************

- name: BANNER_EVENT_DID_LOAD
type: number

- name: BANNER_EVENT_DID_UNLOAD
type: number

- name: BANNER_EVENT_DID_SHOW
type: number

- name: BANNER_EVENT_DID_HIDE
type: number

- name: BANNER_EVENT_DID_CLICK
type: number

- name: BANNER_EVENT_DID_ERROR
type: number

#*****************************************************************************************************

Binary file modified defunityads/lib/android/classes.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#import "UnityAds.h"

@interface NSString (UnityAdsError)
- (UnityAdsError)unityAdsErrorFromString;
@end
107 changes: 107 additions & 0 deletions defunityads/lib/ios/UnityAds.framework/Headers/UADSBanner.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#include <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

/**
* UnityAdsBannerDelegate is a delegate class for callbacks from Unity Ads Banner operations.
*/
@protocol UnityAdsBannerDelegate <NSObject>

/**
Called when the banner is loaded and ready to be placed in the view hierarchy.

@param placementId The ID of the placement of the banner that is loaded.
@param view View that is to be placed in the view hierarchy.
*/
-(void)unityAdsBannerDidLoad:(NSString *)placementId view:(UIView *)view;

/**
Called when the banner is unloaded and references to it should be discarded.
The view provided in unityAdsBannerDidLoad will be removed from the view hierarchy before
this method is called.
*/
-(void)unityAdsBannerDidUnload:(NSString *)placementId;

/**
* Called when the banner is shown.
*
* @param placementId The ID of the placement that has shown.
*/
-(void)unityAdsBannerDidShow:(NSString *)placementId;

/**
* Called when the banner is hidden.
*
* @param placementId the ID of the that has hidden.
*/
-(void)unityAdsBannerDidHide:(NSString *)placementId;

/**
* Called when the user clicks the banner.
*
* @param placementId the ID of the placement that has been clicked.
*/
-(void)unityAdsBannerDidClick:(NSString *)placementId;

/**
* Called when `UnityAdsBanner` encounters an error. All errors will be logged but this method can be used as an additional debugging aid. This callback can also be used for collecting statistics from different error scenarios.
*
* @param message A human readable string indicating the type of error encountered.
*/
-(void)unityAdsBannerDidError:(NSString *)message;
@end

/**
* An enumeration for the various ways to position the Unity Ads banner placement.
*/
typedef NS_ENUM(NSInteger, UnityAdsBannerPosition) {
kUnityAdsBannerPositionTopLeft,
kUnityAdsBannerPositionTopCenter,
kUnityAdsBannerPositionTopRight,
kUnityAdsBannerPositionBottomLeft,
kUnityAdsBannerPositionBottomCenter,
kUnityAdsBannerPositionBottomRight,
kUnityAdsBannerPositionCenter,
kUnityAdsBannerPositionNone
};

/**
* UnityAdsBanner is a static class for handling showing and hiding the Unity Ads banner.
*/

@interface UnityAdsBanner : NSObject

/**
* Loads the banner with the default banner placement.
*/
+(void)loadBanner;

/**
* Loads the banner with the given placement.
* @param placementId The placement ID, as defined in the Unity Ads admin tools.
*/
+(void)loadBanner:(NSString *)placementId;

+(void)setBannerPosition:(UnityAdsBannerPosition)bannerPosition;

/**
* Destroys the banner.
*/
+(void)destroy;

/**
* Provides the currently assigned `UnityAdsBannerDelegate`.
*
* @return The current `UnityAdsBannerDelegate`.
*/
+(nullable id <UnityAdsBannerDelegate>)getDelegate;

/**
* Asigns the banner delegate.
*
* @param delegate The new `UnityAdsBannerDelegate' for UnityAds to send banner callbacks to.
*/
+(void)setDelegate:(id <UnityAdsBannerDelegate>)delegate;
@end

NS_ASSUME_NONNULL_END
4 changes: 2 additions & 2 deletions defunityads/lib/ios/UnityAds.framework/Headers/UADSMetaData.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "UADSJsonStorage.h"
#import "USRVJsonStorage.h"

@interface UADSMetaData : UADSJsonStorage
@interface UADSMetaData : USRVJsonStorage

@property (nonatomic, strong) NSString *category;

Expand Down
14 changes: 14 additions & 0 deletions defunityads/lib/ios/UnityAds.framework/Headers/UANAApiAnalytics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

NS_ASSUME_NONNULL_BEGIN

// C#
@protocol UANAEngineDelegate <NSObject>
-(void)addExtras:(NSString *)extras;
@end

// Webview
@interface UANAApiAnalytics : NSObject
+(void)setAnalyticsDelegate:(id <UANAEngineDelegate>)analyticsDelegate;
@end

NS_ASSUME_NONNULL_END
17 changes: 17 additions & 0 deletions defunityads/lib/ios/UnityAds.framework/Headers/UMONCustomEvent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
NS_ASSUME_NONNULL_BEGIN

@interface UMONCustomEventBuilder : NSObject
@property (nonatomic) NSString* category;
@property (nonatomic) NSString* type;
@property (nonatomic) NSDictionary* userInfo;
@end

@interface UMONCustomEvent : NSObject
@property (strong) NSString* category;
@property (strong) NSString* type;
@property (strong) NSDictionary* userInfo;
-(instancetype)initWithBuilder:(UMONCustomEventBuilder*)builder;
+(instancetype)build:(void (^)(UMONCustomEventBuilder *))buildBlock;
@end

NS_ASSUME_NONNULL_END
15 changes: 15 additions & 0 deletions defunityads/lib/ios/UnityAds.framework/Headers/UMONItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@interface UMONItemBuilder : NSObject
@property(strong, nonatomic) NSString *productId;
@property(nonatomic) double quantity;
@property(strong, nonatomic) NSString *type;
@end

@interface UMONItem : NSObject
+(instancetype)build:(void (^)(UMONItemBuilder *))buildBlock;

-(instancetype)initWithBuilder:(UMONItemBuilder *)builder;

@property(nonatomic, strong, readonly) NSString *productId;
@property(nonatomic, readonly) double quantity;
@property(nonatomic, strong, readonly) NSString *type;
@end