Firebase Offline Support?
I don't know why it seems that every recent Firebase question regarding this has no answer. I made an app on Android Studio using Firebase Authentication and Database that flawlessly syncs online and offline just by following the guide on their site. Unity on the other hand has no support or guide on how to do this. The "guide" on their site seems like a weak attempt to just have something there. It basically just says you can do this and that but we won't tell you how. I managed to get the DB working but not the offline support.
Is offline support even available on Unity?
Answer by greatgirl · Dec 08, 2018 at 05:48 AM
Downloads Firebase Admob Unity Plugin Assets/Plugins is reqired admob_unity_plugin.unitypackage contain all required files and demo files Download those files from Admob Unity3d Plugin Project Home https://github.com/unity-plugins/Firebase-Admob-Unity or Download all the Unity admob plugin project https://github.com/unity-plugins/Firebase-Admob-Unity/archive/master.zip
Installation Firebase Admob Unity Open your project in the Unity editor. Navigate to Assets -> Import Package -> Custom Package. Select the admob_unity_plugin.unitypackage file. Import all of the files for the plugins by selecting Import. Make sure to check for any conflicts with files. Edit AndroidManifest.xml change the appid to your Edit /res/values/strings.xml change google_app_id to your Unzip GoogleMobileAds.framework.zip to GoogleMobileAds.framework Replace GoogleService-Info.plist with your file ,and add this this to your xcode project Add other link flag -ObjC in xcode project Unity Plugin Wiki and Documentation API Tutorial Quick Start Google Firebase Analyze FirebaseAnalytic firebase=FirebaseAnalytic.Instance();//init and start basic analysis //you can set more info as follow ,but this is optional firebase.logEvent("startevent", "{\"player\":\"yingke\"}"); firebase.setUserId("232324432"); firebase.setUserProperty("age", "20"); // firebase.setAnalyticsCollectionEnabled(true); 1.Init Firebase Admob Unity Plugin Create A C# script ,drag the script to a object on scene , add the follow code in the script file
using admob;
Admob.Instance().initSDK("admob id", new AdProperties());//admob id with format ca-app-pub-279xxxxxxxx~xxxxxxxx
2.Add Admob Banner in Unity App Here is the minimal code needed to show admob banner.
Admob.Instance().showBannerRelative("your banner id",AdSize.Banner, AdPosition.BOTTOM_CENTER, 0);
The AdPosition class specifies where to place the banner. AdSize specifies witch size banner to show
3.Remove Banner By default, banners are visible. To temporarily hide a banner, call:
Admob.Instance().removeBanner();
4.How to integrate Interstitial into Unity 3d app? Here is the minimal code to create an interstitial.
Admob.Instance().loadInterstitial("your interstitial id");
Unlike banners, interstitials need to be explicitly shown. At an appropriate stopping point in your app, check that the interstitail is ready before showing it:
if (Admob.Instance().isInterstitialReady()) {
Admob.Instance().showInterstitial();
}
5.Custom Admob Banner Ad Sizes In addition to constants on AdSize, you can also create a custom size:
//Create a 250x250 banner.
AdSize adSize = new AdSize(250, 250);
Admob.Instance().showBannerAbsolute("your banner id",adSize,0,30);
6.Admob settings If you want to test the ads ,non personalize ads,set tag for family or set tag for children market,you can set with admob unity plugin easy
AdProperties adProperties = new AdProperties();
adProperties.isTesting = true;
adProperties.isForChildDirectedTreatment=true;
//adProperties.isUnderAgeOfConsent=true;
adProperties.isAppMuted=true;
adProperties.nonPersonalizedAdsOnly=true;
7.Ad Events Both Banner and Interstitial contain the same ad events that you can register for. Here we'll demonstrate setting ad events on a interstitial,and show interstitial when load success:
Admob.Instance().interstitialEventHandler += onInterstitialEvent;
void onInterstitialEvent(string eventName, string msg)
{
Debug.Log("handler onAdmobEvent---" + eventName + " " + msg);
if (eventName == AdmobEvent.onAdLoaded)
{
Admob.Instance().showInterstitial();
}
}
You only need to register for the events you care about.
8.How to integrate Admob Rewarded Video to Unity3d app? Here is the minimal code to create an admob video.
Admob.Instance().loadRewardedVideo("ca-app-pub-312xxxxxxxxxxxx/xxxxxxxx");
Simular with interstitial,video need to be explicitly shown at an appropriate stopping point in your app, check that the video is ready before showing it:
if (Admob.Instance().isRewardedVideoReady()) {
Admob.Instance().showRewardedVideo();
}
9.Show Admob Advance Native Ad in IOS and Android App Here is the minimal code needed to show admob banner. This is implemented with Admob Native Advanced as AdMob announced stop the express format ads
Admob.Instance().showNativeBannerRelative("native ad id",new AdSize(360,100), AdPosition.BOTTOM_CENTER, 0,"defaultNativeBanner");
The AdPosition class specifies where to place the banner. AdSize specifies witch size banner to show
10.Remove Admob Native Banner By default, banners are visible. To temporarily hide a banner, call:
Admob.Instance().removeBanner("defaultNativeBanner");
Important Tips If you not config AndroidManifest.xml,APP will crash Attach admob to Object on scene,init admob before call admob fun Add GoogleService-Info.plist to your xcode project,otherwise,APP will crash Add Link Flag -ObjC to your xcode project,otherwise,APP will crash Unzip GoogleMobileAds.framework.zip to GoogleMobileAds.framework Edit res/values/string.xml and set the appid to your
Your answer
Follow this Question
Related Questions
Input Dispatching issue ANR reports in Unity 3D Game on Android platform 0 Answers
SQL Unity Android 0 Answers
Send command to unity android application 0 Answers
mobile device restarts when game is uninstalled 0 Answers
how to define a user id securely 0 Answers