Getting started with cross-promotion Showcase🔗
In order to integrate cross-promotion Showcase you need to follow these simple steps:
Step 1. Import cross-promotion module🔗
-
Add MRGSShowcase module
Unity:
Adding to the project (general instruction)
Step 1. Add Sources
To add MRGS to a project via the Unity Package Manager (available from Unity 2018+) simply add a
scopedRegistriessection to thePackages/manifest.jsonfile by adding the following entry:{ "dependencies": { ... }, "scopedRegistries": [ { "name": "MRGS", "url": "https://mrgs-nexus.my.games/repository/mrgs-uninty-plugins/", "scopes": [ "games.my.mrgs" ] } ] }Alternatively, you can click
Edit -> Project Settings -> Package Manager -> '+' in scoped registry section, and fill in the fields according to the data above.Step 2. Add dependency
- Click
Window -> Package Manager -> select 'Packages: MyRegistries' from dropdown list, select packageMRGSShowcasefrom the list, then click "Install" - Import the module:
using MRGS;
- Download the latest version of the library. Unzip the archive.
- (For unitypackage integration) In Unity, click
Assets -> Import Package -> Custom Package, and select thegames.my.mrgs.showcase.unitypackagepackage from the downloaded archive. - (For tgz integration) In Unity, click
Window -> Package Manager -> '+' -> Add package from tarball, and select thegames.my.mrgs.showcase-<version> package. tgzfrom the downloaded archive. - Import the module:
using MRGS;
iOS:
Adding to the project (general instruction)
Step 1: Add dependencies
Via Package collection
- In Xcode select File > Add Packages
- Select "+" > "Add Swift Package Collection"
- Insert URL:
https://mrgs-nexus.my.games/repository/ios-sdks/MRGSPackageCollection.json - Select module MRGSShowcase from "MRGS Package Collection".
- Or you can select "MRGS" package from "MRGS Package Collection" (contains all mrgs modules as products) and then select "MRGS/Showcase" product only.
Individual packages
- In Xcode select File > Add Packages
- In the search bar at the top right, paste the URL:
https://mrgs-gitea.my.games/mrgs/mrgsshowcase-ios-sdk.git - Add a module to your project
- Or you can paste the url
https://mrgs-gitea.my.games/mrgs/ios-sdks.gitto include the "MRGS" package which contains all mrgs modules as products and then select only the product" MRGS/Showcase".
Step 2: Add support for ObjectiveC categories
- Set the
-ObjCflag in the "Other linker Flags" field in the project settings. - Import the module in code:
@import MRGServiceKit;or@import MRGSShowcase;or#import <MRGSShowcase/MRGSShowcase.h>
Step 1. Add Sources
In your podfile, add sources to the top of the file:
source 'https://github.com/CocoaPods/Specs.git' # For main repo source 'https://mrgs-gitea.my.games/mrgs/cocoapods-specs.git' # For MRGS repoStep 2: Add dependencies
Add the latest version of MRGSShowcase to target:
To add via subspecs:
To add via individual modules:
To add all mrgs modules:
Step 3: Install dependencies
- Run
pod install(orpod install --repo-updateif necessary) - Import the module in code:
@import MRGServiceKit;or@import MRGSShowcase;or#import <MRGSShowcase/MRGSShowcase.h>
Step 1: Add dependencies
Add the dependency to your Cartfile:
Step 2: Install dependencies
- Run
carthage update --use-xcframeworks - Add downloaded frameworks to your project (make sure "do not embed" option is enabled)
- Set the
-ObjCflag in the "Other linker Flags" field in the project settings. - Import the module in code:
@import MRGServiceKit;or@import MRGSShowcase;or#import <MRGSShowcase/MRGSShowcase.h>
- Download the latest version of the library. Unzip the archive.
-
Add
MRGSShowcase.xcframeworkfrom the downloaded archive to your project (Drag the libraries to the "Linked frameworks and Libraries" section) (Also contains MRGSShowcase.framework for compatibility - fat framework) -
Set the
-ObjCflag in the "Other linker Flags" field in the project settings. - Import the module in code:
@import MRGSShowcase;or#import <MRGSShowcase/MRGSShowcase.h> - Also, you can add the
MRGServiceKit.handmodule.modulemapfiles from the archive to your project, or specify the path to them in the project settings in theBuild Settings -> Header search pathssection. Now, instead of importing each of our frameworks separately, you can only import one header file:@import MRGServiceKit;
Android:
Add a dependency in
build.gradlefile:Copy the MRGSShowcase.aar file into the libs directory of your project. Add the necessary dependencies to the build.gradle file:
dependencies { //... implementation(name: 'MRGSShowcase', ext:'aar') implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.recyclerview:recyclerview:1.2.1' implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0' implementation 'androidx.vectordrawable:vectordrawable:1.1.0' } - Click
Step 2. Delegate setup🔗
Next you need to set up a delegate (see the comment in the code below) to receive notifications.
// Set a listener of a new content event, where this - implementation of MRGSShowcase.OnNewContentListener
MRGSShowcase.getInstance().setNewContentListener(this);
// // Set a listener of a close showcase event, where this - implementation of MRGSShowcase.OnShowListener
MRGSShowcase.getInstance().setShowListener(this);
Next, you need to implement the methods of the delegate, that you've set earlier:
// Will be called when Showcase has something new and not yet seen by the user
// If this method is called, you need to mark the path to Showcase with circles in the game
public void OnReceiveNewShowcaseContent(int numberOfNewEvents)
{
Debug.Log("Received new events in MRGSShowcase - " + numberOfNewEvents);
// Show the user an invitation to open Showcase
}
// Will be called when Showcase has something new and not yet seen by the user
//If this method is called, you need to mark the path to Showcase with circles in the game
-(void)didReceiveNewShowcaseContent:(NSNumber *)numberOfNewEvents{
NSLog(@"Received didReceiveNewShowcaseContent delegate callback with number - %@", numberOfNewEvents);
// Show the user an invitation to open Showcase
}
// Will be called when Showcase has something new and not yet seen by the user
//If this method is called, you need to mark the path to Showcase with circles in the game
void onNewContent(int countContents){
// Show the user an invitation to open Showcase
}
void onShowFinished(){
// Will be called after showcase close
}
This delegate is needed so that when it is called, you could show the user a notification, or mark the path to the showcase with markers with numbers, indicating that there are new offers for the user.
Step 3. Display the showcase🔗
Use the following method to display it:
This is only relevant to Android.
Currently Unity games for Android only supports the main Unity Activity to have launchMode of singleTask. See Unity document for the Android manifest and the Android document for activity.
Because we use Activity to show Showcase, the activity could be destroyed without being properly closed when a user backgrounds an app and then relaunch it using the icon - and not the app switcher. In this case, you will also receive an event about the closing of the Showcase.
Make sure ads are set up on the server
During the first integration, if you receive a loading error, you need to make sure that creatives and campaigns are created on the MRGS server. In case of such problems, to check and launch test campaigns, please contact the contact indicated on the page with integration steps.
Example🔗
// Set a delegate
MRGSShowcase.Instance.Delegate = this;
// ...
// Implementation of the delegate
public void OnReceiveNewShowcaseContent(int numberOfNewEvents)
{
Debug.Log("Received new events in MRGSShowcase - " + numberOfNewEvents);
// Show the user an invitation to open Showcase
}
// ...
// Call to show content:
MRGSShowcase.Instance.Present(() => {
Debug.Log("MRGSShowcase closed callback");
// Will be called after closing Showcase
});
// Set a delegate
[MRGSShowcase sharedInstance].delegate = self;
// ...
// Delegate implementation
-(void)didReceiveNewShowcaseContent:(NSNumber *)numberOfNewEvents{
NSLog(@"Received didReceiveNewShowcaseContent delegate callback with number - %@", numberOfNewEvents);
// Show the user an invitation to open Showcase
}
// ...
// Call to show content:
[[MRGSShowcase sharedInstance] presentShowcaseFromViewController:self withCompletionHandler:^{
NSLog(@"Received callback on closing MRGSShowcase");
// Will be called after closing Showcase
}];
// Set listeners
MRGSShowcase.getInstance().setNewContentListener(this);
MRGSShowcase.getInstance().setShowListener(this);
// ...
// Implementations of listeners
void onNewContent(int countContents){
// Show the user an invitation to open Showcase
}
void onShowFinished(){
// Will be called after closing Showcase
}
// ...
// Call to show content:
MRGSShowcase.getInstance().showContent();
Features for Android🔗
Changing the screen orientation🔗
By default, the Showcase inherits the behavior of the parent Activity, using the settings android:screenOrientation="behind". If you need to change this behavior, you can override the settings in your AndroidManifest.xml file, by changing behind to any other desired parameter. See. supported parameters for android:screenOrientation
Example with sensorLandscape - supports horizontal mode in both directions (determined by the device sensor):
<manifest
...
xmlns:tools="http://schemas.android.com/tools">
<application>
...
<activity
android:name="games.my.mrgs.showcase.internal.ui.showcase.ShowcaseActivity"
android:configChanges="orientation|screenSize"
android:launchMode="singleTop"
android:screenOrientation="sensorLandscape"
android:theme="@style/MrgsShowcaseTheme"
tools:replace="android:screenOrientation"/>
</application>
</manifest>
Testing🔗
Since we update the data on new available campaigns every 6 hours since the last login to Showcase upon application launch, we added several methods of testing.
Use the following methods for testing:
// Clear cache
// When testing the delegate, it is necessary that the delegate indicating new bonuses must be called when clearing the cache during the next launch
MRGSShowcase.Instance.ClearCache();
// Clear downloaded data (images) of the campaigns
// This method can be used to test the "clean" launch of Showcase without pre-loaded data
MRGSShowcase.Instance.ClearLoadedData();
// Clear cache
// When testing the delegate it is necessary that the delegate indicating new bonuses must be called when clearing the cache during the next launch
[[MRGSShowcase sharedInstance] clearShowcaseCache];
// Clear the downloaded data (images) of the campaigns.
// This method can be used to test the "clean" launch of Showcase without pre-loaded data
[[MRGSShowcase sharedInstance] clearShowcaseLoadedData];
// Clear cache
// When testing the delegate it is necessary that the delegate indicating new bonuses must be called when clearing the cache during the next launch
MRGSShowcase.getInstance().clearCache();
// Clear the downloaded data (images) of the campaigns.
// This method can be used to test the "clean" launch of Showcase without pre-loaded data
MRGSShowcase.getInstance().clearLoadedData();
Created: 2021-03-19