Getting started with cross-promotion (Game Center)🔗
In order to integrate cross-promotion (Game Center) you need to follow these simple steps:
Step 1. Import cross-promotion module🔗
-
Add MRGSGameCenter 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 packageMRGSGameCenterfrom 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.gamecenter.unitypackagepackage from the downloaded archive. - (For tgz integration) In Unity, click
Window -> Package Manager -> '+' -> Add package from tarball, and select thegames.my.mrgs.gamecenter-<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 MRGSGameCenter from "MRGS Package Collection".
- Or you can select "MRGS" package from "MRGS Package Collection" (contains all mrgs modules as products) and then select "MRGS/GameCenter" 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/mrgsgamecenter-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/GameCenter".
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 MRGSGameCenter;or#import <MRGSGameCenter/MRGSGameCenter.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 MRGSGameCenter 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 MRGSGameCenter;or#import <MRGSGameCenter/MRGSGameCenter.h>
Step 1: Add dependencies
Add the dependency to your Cartfile:
binary "https://mrgs-nexus.my.games/repository/ios-sdks/MRGSGameCenter/MRGSGameCenter.json" ~> 5.0.0Step 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 MRGSGameCenter;or#import <MRGSGameCenter/MRGSGameCenter.h>
- Download the latest version of the library. Unzip the archive.
-
Add
MRGSGameCenter.xcframeworkfrom the downloaded archive to your project (Drag the libraries to the "Linked frameworks and Libraries" section) (Also contains MRGSGameCenter.framework for compatibility - fat framework) -
Add bundle with resources:
- Add
MRGSGameCenterResources.bundleto the project by dragging it into the project structure. - Go to the "Copy Bundle Resources" section in the "Build Phases" tab, click "+", and select the desired bundle.
- Add
-
Set the
-ObjCflag in the "Other linker Flags" field in the project settings. - Import the module in code:
@import MRGSGameCenter;or#import <MRGSGameCenter/MRGSGameCenter.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 MRGSGameCenter.aar file into the libs directory of your project. Add the necessary dependencies to the build.gradle file:
dependencies { //... implementation(name: 'MRGSGameCenter', 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 the MRGSGamecenterClientDelegate delegate to receive notifications.
Next, you need to implement the methods of the MRGSGamecenterClientDelegate delegate, that you've set earlier:
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, indicating that there are new offers for the user.
Step 3. Display the showcase🔗
Use the following method to display it:
- (void) showGameCenterfromViewController:(nullable UIViewController*)controller withSocialClassObject:(nullable MRGSGameCenterSocialClass*)socialInfo completion:(void (^ __nullable)(BOOL))completion;
I.e:
[[MRGSGameCenter sharedInstance] showGameCenterfromViewController:self withSocialClassObject:socialInfoFromApp completion:^(BOOL _) {
//This code will be executed after closing Game Center
}];
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
MRGSGameCenter.Instance.Delegate = this;
// ...
// Implementation of the delegate
public void OnGameCenterHasNewBonuses()
{
// Here we use markers to indicate the path to the button that opens the showcase
}
// ...
// Call this method to show content:
MRGSGameCenter.Instance.Show();
// Delegate setup
[MRGSGameCenter sharedInstance].delegate = self;
// ...
// Delegate implementation
-(void)gameCenterHasNewBonuses{
// Here we use markers to indicate the path to the button that opens the showcase
}
// ...
// Call this method to show content:
[[MRGSGameCenter sharedInstance] showGameCenterfromViewController:self withSocialClassObject:nil completion:^(BOOL _) {
//This code will be executed after closing Game Center
}];
Testing🔗
Since we update the data on new available campaigns every 12 hours since the last login to Game Center upon application launch, we added several methods of testing.
Use the following methods for testing:
// Clear server 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
MRGSGameCenter.Instance.ClearCache()
// Clear downloaded data (images) of the campaigns
// This method can be used to test the "clean" launch of Game Center without pre-loaded data
MRGSGameCenter.Instance.ClearLoadedData()
// Clear the server 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
[[MRGSGameCenter sharedInstance] clearGameCenterCache];
// Clear the downloaded data (images) of the campaigns.
// This method can be used to test the "clean" launch of Game Center without pre-loaded data
[[MRGSGameCenter sharedInstance] clearGameCenterLoadedData];
What to do if there are problems with localization on iOS?
Localization issues may occur on iOS. We use native localization, therefore, it must be supported by the project. Thus, if you have problems with localization, check:
First option (more correct and promising):
- Make sure there are at least Russian and English languages present in the localization menu item in the project settings
- Make sure there is at least one
Localizble.stringsfile (even if it's empty), and it is localized into Russian and English, and it is added to the build target (as a result there will be folders withlanguage.lprojnames in the assembled application) - The default project(XCode) localization language must be set to English.
Second option (manual indication of supported languages):
Add the following key into Info.plist of the application:
Automatic key addition from the second option in Unity is described here.
Created: 2020-03-02