Compatibility

iOS: The Megacool SDK supports iOS 7+, but GIF capturing is only supported on iOS 8+.
Android: The Megacool SDK supports Android API level 18 (4.3.x, Jelly Bean) and up.

Latest SDK version

2.5.1

Overview

The Megacool SDK provides two ways to boost user growth:

  • Make it easy to share GIF moments
  • Incentivize users to refer their friends

This quickstart guide will help you set up the basic functionality of the Megacool SDK:

Step 1: Configure app on the dashboard
Step 2: Install the Megacool SDK
Step 3: Share a recorded GIF
Step 4: Create referrals

Step 1: Configure an app on the dashboard

Go to the dashboard and create a new app. Come back here when you're done, ensure you refresh the page so that you'll see app config you need.


Step 2: Install the Megacool SDK

Download the Unity package from the big pink button above, then import it to your project through Assets -> Import Package -> Custom package.

A new menu bar item called Megacool appears. Open it and press Configuration and fill out:

  • App Config (iOS): YOUR_APP_CONFIG * Required

  • App Config (Android): YOUR_APP_CONFIG * Required

  • URL Scheme (iOS): YOUR_URL_SCHEME
  • URL Scheme (Android): YOUR_URL_SCHEME

These enable deep-linking to your app.

Set your Bundle Identifier and iOS Developer Team ID if you haven't already: File --> Build Settings --> Player Settings --> Other Settings --> Identification:

  • Bundle Identifier: YOUR_BUNDLE_ID

  • iOS Developer Team ID: YOUR_APPLE_TEAM_ID

Press the Save changes button when you're done.

Initialize the SDK

Go to the folder Assets->Megacool->Prefabs and drag the MegacoolManager prefab onto your scene. Feel free to make your own implementation in case you don't use Camera.main.

Start Megacool as the first thing when the app opens.

void Start() {
Megacool.Instance.Start();
}

Step 3: Share a recorded GIF

It's time to record and generate a GIF! There are two ways to record the screen:

A) Time recording

Add the following line of code where you want to start a recording:

Megacool.Instance.StartRecording();

The recording will by default keep a buffer of the last 5 seconds. Old frames get overwritten by new frames. You can customize this later.

To stop a recording, add the following line of code:

Megacool.Instance.StopRecording();

B) Capture individual frames

Capture each frame of the recording, e.g. on each user tap:

Megacool.Instance.CaptureFrame();

By default max 50 frames will be captured. If it exceeds 50 frames, old frames are overwritten until Megacool.Instance.StopRecording gets called to reset it. Add the following line of code to stop a recording:

Megacool.Instance.StopRecording();

Share the GIF

Add the following line of code to share the recorded GIF. A modal share view will pop up with the option to share to different channels.

Megacool.Instance.Share();

Do a test run!

Note: In case you have another SDK that also subclasses the UnityAppController, you have to merge MegacoolAppController to make link handling work for both. Check out an example merge with Tune SDK (TuneAppController.m): MergeUnityAppController.m. Remember to delete the original files after merging into a new file.

Build your project to a device.

Do a test run to see if the GIF capturing and sharing work. Send a message to yourself and verify that the link opens the app again.


Step 4: Create a referral

In a game where players need currency, you can incentivize them to invite their friends instead of watching an ad. It’s simple to give a reward after a friend has installed the app.

Add a refer friend button that calls Megacool.Instance.Share with a custom share config. We recommend adding referral to the url so it becomes mgcl.co/game/referral?_m=123

string urlExtension = "referral";
MegacoolShare share = new MegacoolShare(urlExtension);
Megacool.Instance.Share(new MegacoolShareConfig {
Share = share
});

Expand Start to receive the callback from the server when a share has been opened on a new device:

void Start() {
Megacool.Instance.Start(e => {
if (e.Type == MegacoolEvent.MegacoolEventType.SentShareOpened) {
// A share sent from this device has been opened
if(e.FirstSession){
//First session means your friend just installed the app
Debug.Log("Give reward!");
}
}
});
}



Well done, this should be enough to get you started! To optimize the recording and share experience, continue to customization.


Notice

We strongly believe in not crashing your apps. But, since networking and computers are inherently unreliable, stuff sometimes fails. To prevent your users from noticing these failures, you should always be prepared for our API calls to return nil or other signals of failure, and have a plan if that happens. This can happen if your app runs out of memory, disk is full, or some other bug is present which prevents us from delivering the expected value from our API calls. We strongly believe in the philosophy of progressive enhancement, and this is your best way for interacting with our API as well. In practice, always assume that our tools fail, but rejoice when they are working as promised.

Note: In the case of severe performance regressions, bugs on certain platforms, we can disable some of our features remotely. This would have the same effect as a feature not working. Thus it's easy to test the error conditions locally.