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

3.0.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

Start Megacool as the first thing when the app opens:

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

Note: Make sure your app has a main camera, as we'll fall back to recording from that on devices that don't support direct capturing from the screen. Alternatively you can select a custom camera to use.


Step 3: Share a recorded GIF

It's time to record and generate a GIF! There are three main 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) Highlight recording

The highlight recording feature records the ‘most interesting’ part of your game--whether this is an awesome action sequence, or a hilarious ‘fail’. It does this by keeping track of the gameplay's intensity as determined by metrics specific to your game.

Whenever a critical event (such as scoring a point, landing a cool combo, failing in an epic way, etc) occurs, call this function to make note of the event (and optionally, its intensity):

Megacool.Instance.RegisterScoreChange(); //(without intensity)
Megacool.Instance.RegisterScoreChange(42); //(with intensity of 42)

For easy integration, we suggest ‘piggy-backing’ off your game’s current score system by calling this function whenever the player’s score increases, with the amount that it increases by. We equate ‘intensity’ with a change in point value, but you can also experiment with assigning various intensities to events with subjective ‘cool’ value.

Add the following line of code at the beginning of your game to start capturing your highlight!

Megacool.Instance.StartRecording (new MegacoolRecordingConfig {
OverflowStrategy = MegacoolOverflowStrategy.HIGHLIGHT
});

C) 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

Megacool.Instance.Share(new MegacoolShareConfig {
Url = new Uri("referral", UriKind.Relative),
});

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

Note: Ensure you register the callbacks before calling Megacool.Instance.Start() to ensure you don't lose any events, as the callbacks might get called already during that call.

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

The callback with new events gets triggered when the SDK occasionally communicates with the server. To reward a user right after a new install has occurred, you can add a "refresh" button that calls GetShares. The GetShares method is used for checking the status of sent shares, but it also requests the server for new events.

void RefreshButton() {
Megacool.Instance.GetShares(shares => {});
}



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.