Skip to main content

Campaign Integration

Prerequisites

  • Unity LTS 2019 above
  • For Android
    • Minimum API Level 19 or above
    • Target API Level 33 or above
    • Gradle 6.7.1 or above
  • For iOS
    • iOS 12.0 or above.
    • Xcode 14.3 or above
    • Cocoapods 1.10.0 or above

Download

Unity Plugin (latest): Click here to download

  • From v1.0.0-beta.2, the SDK changed SmartPolly to FanCraft, if you want to upgrade, please follow these steps to upgrade
    • Remove Assets/Yodo1/SmartPolly and Assets/Plugins/Android/SmartPolly.androidlib folders
    • Import the new unitypackage
    • Reset configuration settings in the Unity editor
    • Replace SmartPolly with FanCraft in the codes

Install Config

Android Unity Config:

This setting can be ignored if the Firebase Cloud Message service has already been directly or indirectly integrated.

FanCraftUnity:google_app_id <=> google-services.json:mobilesdk_app_id
FanCraftUnity:google_api_key <=> google-services.json:current_key
FanCraftUnity:project_id <=> google-services.json:project_id

FanCraft SDK Initialization

To initialize the FanCraft SDK you need to get your App_Key first. Each of you game will have a different App_Key, double-check before you start the SDK initialization.

We recommend you to initialize the SDK as soon as possible after launching your game. This could ensure the SDK captures all relevant settings/configurations and all other in-game events.

FanCraftSDK.Init(
"{your_app_key}",
GameUserSettings gameUserSettings, // including user info | enable = true/false, GameUserInfo(userId, nickName, realName, age, email, phoneNumber, userTag)
PrivacySettings privacySettings, // including coppa, gdpr, ccpa
PushNotificationSettings pushNotificationSettings, // enable = true/false
SDKConfiguration sdkConfiguration,
(SDKInitSuccessInfo initSuccessInfo, FanCraftError error) => {
if (error) {
// Initialization failed
} else {
// Initialization success
FanCraftUserInfo userInfo = initSuccessInfo.GetUserInfo();
}
}
);

The SDK init method will require you four params or settings, you can following the instructions below to finish the set up properly.

GameUserSettings

FanCraft will help you to identify users. In general, all users in FanCraft are anonymous. So if your game don’t have a user system, you can just init the GameUserSettings by set enable to false.

However, remember to enable it if your game build the user system already, please provide the information you have. This will help you to identify you users. Such as, sending them a reward, notification, etc.

GameUserInfo gameUserInfo = new GameUserInfo();
gameUserInfo.UserId = "{{user_id}}";
gameUserInfo.NickName = "{{nickname}}"; // optional
gameUserInfo.RealName = "{{real_name}}"; // optional
gameUserInfo.Age = 10; // optional
gameUserInfo.Email = "{{email}}"; // optional
gameUserInfo.PhoneNumber = "{{phone_number}}"; // optional
gameUserInfo.UserGender = GameUserInfo.Gender.Male; // optional
~~gameUserInfo.UserTag = "{{user_tag}}"; // It is optional but highly recommended to set up the correct tag. The tag can help you identify user groups.~~

GameUserSettings gameUserSettings = new GameUserSettings();
gameUserSettings.Enable = true;
gameUserSettings.UserInfo = gameUserInfo;

PrivacySettings

Privacy settings is help you to avoid the privacy violations, such as CCPA, COPPA, GDPR, etc. You need to tell FanCraft which privacy settings you want to enable, and handling each privacy policy by yourself.

PrivacySettings privacySettings = new PrivacySettings();
privacySettings.SetGDPR = true;
privacySettings.SetCCPA = true;
privacySettings.SetCOPPA = true;

PushNotificationSettings

To enable the system-level push notification, you need to tell FanCraft the proper device token. Here’s the guidance for how to finish the set ups and get the token for AppStore and GooglePlay.

PushNotificationSettings pushNotificationSettings = new PushNotificationSettings();        
pushNotificationSettings.Enable = true;
pushNotificationSettings.DeviceToken = "{{device_token}}";

SDKConfiguration (Theming)

SDK configuration is for further usage, such as different logo, skin, etc. Right now you can just set up to default value.

SDKConfiguration sdkConfiguration = SDKConfiguration.defaultConfig();

// Customization interstitial notification theming
sdkConfiguration.InterNotificationTheme.TitleFontSize = 20; // Title Font Size - For title size in all notifications except Image.
sdkConfiguration.InterNotificationTheme.DescriptionFontSize = 16; // Description Font Size - For Text Poll description, Image Poll description, and Poll option text size.
sdkConfiguration.InterNotificationTheme.CtaFontSize = 18; // For CTA button font size

sdkConfiguration.InterNotificationTheme.OverlayColor = new Color(128f/255f, 128f/255f, 128f/255f, 0.5f); // For setting the color of the grey overlay we show when a notification opens, i.e. what if someone wants it to be white?
sdkConfiguration.InterNotificationTheme.PopupBackgroundColor = new Color(226f/255f, 226f/255f, 226f/255f, 1.0f); // Popup Background Color - For background color of the popup in text, image, poll_image, poll notifications.
sdkConfiguration.InterNotificationTheme.CtaBackgroundColor = new Color(208f/255f, 208f/255f, 208f/255f, 1.0f); // CTA Background Color - For CTA button background color.
sdkConfiguration.InterNotificationTheme.PollOptionBackgroundColor = new Color(208f/255f, 208f/255f, 208f/255f, 1.0f); // Poll Option Background Color - For the background color of the poll option.

sdkConfiguration.InterNotificationTheme.TextColor = Color.black; // Text Color - For all text unless specifically overridden
sdkConfiguration.InterNotificationTheme.TitleColor = Color.black; // Title Color - If set, this will override “Text Color” for titles in all notifications.
sdkConfiguration.InterNotificationTheme.CtaTextColor = Color.black; // CTA Text Color - Color for CTA button text.
sdkConfiguration.InterNotificationTheme.PollOptionTextColor = Color.black; // Poll Option Text Color - For Poll Option text color.

User Tags

The method allow the developers to tag a player at specific parts of their game play

string[] tags = new string[] { "tag1", "tag2" };

FanCraftSDK.SetTags(tags, (bool status, FanCraftError error) => {
Debug.Log(FanCraftSDK.TAG + string.Format("SetTags - status:{0}", status));
if (error != null)
{
Debug.Log(FanCraftSDK.TAG + string.Format("SetTags - error({0}, {1})", error.Code, error.Message));
}
});
FanCraftSDK.SetTag("your_user_tag", (bool status, FanCraftError error) => {
Debug.Log(FanCraftSDK.TAG + string.Format("SetTags - status:{0}", status));
if (error != null)
{
Debug.Log(FanCraftSDK.TAG + string.Format("SetTags - error({0}, {1})", error.Code, error.Message));
}
});

Notification

The notification is the most powerful function in FanCraft. To make it clear, we start with the concept. Notifications or Campaigns can be setup using he dashboard https://smart-polly.yodo1.net/

Notification Type

  • Text
  • Text-image
  • Image
  • Poll
  • Poll-image

Notification Action

  • External
  • In-app
  • Reward

Notification Rewards

When a notification is configured from the FanCraft dashboard, the dashboard user can tie to a reward which the game can attach to a user’s profile once a specific CTA is fulfilled. To capture the rewards you may choose to add a handler like this to listen to Interstitial notification events.

FanCraftSDK.ShowInterstitialNotification((string noticiation_id, FanCraftError error, InterstialNotificationHandler handler) => {
handler.GetNotificationType; // text|text-image|image|poll|poll-iamge
InterstialNotificationEvent interstialNotificationEvent = handler.GetNotificationEvent; // event
handler.GetRewards; // reward list
handler.GetAction; // action external|in-app|reward

switch (interstialNotificationEvent)
{
case FanCraftSDK.InterstialNotificationEvent.InterstitialNotificationWillAppear: // soon appear
// game pause
break;
case FanCraftSDK.InterstialNotificationEvent.InterstitialNotificationDidCancel: // canclled, closed by user
// game resume
break;
case FanCraftSDK.InterstialNotificationEvent.InterstitialNotificationDidEngagen: // Should SDK close notification? Need to be discussed
// game resume
if (rewards != null && rewards.Count > 0) {
// Attach the reward to the user's profile
}
break;
default:
break;
}
});

This method allow the developers to show interstitial notifications by a special location id (You can input a location id when you create a new notification in the dashboard)