Flutter Plugin for TapJoy SDK - Supports Android & iOS This Plugin Does NOT Support TapJoy purchases or Push Notifications yet.
Medium Article on how to implement the plugin
TapJoy is enrolled as a network partner in Apple’s SKAdNetwork. Add Tapjoy's network ID to your app’s info.plist
file along with the IDs of the DSP partners listed below:
<key>SKAdNetworkItems</key>
<array>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>ecpz2srf59.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>7ug5zh24hu.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>9t245vhmpl.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>prcb7njmu6.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>5lm9lj6jb7.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>578prtvx9j.skadnetwork</string>
</dict>
</array>
iOS 14.0 or higher required App Tracking Authorization from the user.
add the following lines to info.plist
file.
<key>NSUserTrackingUsageDescription</key>
<string>This allows us to deliver personalized ads for you.</string>
Comment out the following line in your iOS Podfile
target 'Runner' do
# use_frameworks!
use_modular_headers!
The following permissions are needed:
- INTERNET
- ACCESS_NETWORK_STATE
- ACCESS_WIFI_STATE (optional)
add the following permissions to your AndroidManifest.xml
file:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
add the following activities to the AndroidManifest.xml
file in the Application block:
<activity
android:name="com.tapjoy.TJAdUnitActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:hardwareAccelerated="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity
android:name="com.tapjoy.TJContentActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:hardwareAccelerated="true" />
As part of your Google Play Services integration, you will have to add the following:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
TapJoyPlugin.shared.connect(androidApiKey: “your-tapjoy-android-key”,
iOSApiKey:"your-tapjoy-iOS-key",debug: true);
TapJoyPlugin.shared.setConnectionResultHandler((result) {
switch (result) {
case TJConnectionResult.connected:
// TODO: Handle this case.
break;
case TJConnectionResult.disconnected:
// TODO: Handle this case.
break;
}
});
TapJoyPlugin.shared.getIOSATTAuth().then((value) {
switch(value) {
case IOSATTAuthResult.notDetermined:
// TODO: Handle this case.
break;
case IOSATTAuthResult.restricted:
// TODO: Handle this case.
break;
case IOSATTAuthResult.denied:
// TODO: Handle this case.
break;
case IOSATTAuthResult.authorized:
// TODO: Handle this case.
break;
case IOSATTAuthResult.none:
// TODO: Handle this case.
break;
case IOSATTAuthResult.iOSVersionNotSupported:
// TODO: Handle this case.
break;
case IOSATTAuthResult.android:
// TODO: Handle this case.
}
});
TapJoyPlugin.shared.setUserID(userID: "user_id");
TJPlacement placement = TJPlacement(name: "TapJoyPlacementName");
TJPlacementHandler handler = (contentState,name,error) {
switch(contentState) {
case TJContentState.contentReady:
// TODO: Handle this case.
break;
case TJContentState.contentDidAppear:
// TODO: Handle this case.
break;
case TJContentState.contentDidDisappear:
// TODO: Handle this case.
break;
case TJContentState.contentRequestSuccess:
// TODO: Handle this case.
break;
case TJContentState.contentRequestFail:
// TODO: Handle this case.
break;
case TJContentState.userClickedAndroidOnly:
// TODO: Handle this case.
break;
}
};
placement.setHandler(handler);
await placement.requestContent();
await placement.showPlacement();
TapJoyPlugin.shared.setGetCurrencyBalanceHandler((currencyName,
amount, error) { });
await TapJoyPlugin.shared.getCurrencyBalance();
TapJoyPlugin.shared.setAwardCurrencyHandler((currencyName,
amount, error) { });
TapJoyPlugin.shared.awardCurrency(int amount);
TapJoyPlugin.shared.setSpendCurrencyHandler((currencyName,
amount, error) { });
TapJoyPlugin.shared.spendCurrency( int amount );
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.