Google Play Services Unity Plugin not Show Leaderboard - android

I am building a game for Android with Unity 5, and I have imported this plugin
But it's not working properly I followed this tutorial :
When I try to post or show leaderboard , it does not show anything .It does not even throw any error. Sign-in and out are working properly.Please help
Code :
public void LogIn ()
{
Social.localUser.Authenticate ((bool success) =>
{
if (success) {
Debug.Log ("Login Sucess");
} else {
Debug.Log ("Login failed");
}
});
}
public void LogOut ()
{
PlayGamesPlatform.Instance.SignOut ();
}
public void Post ()
{
if (Social.localUser.authenticated) {
Social.ReportScore (5000, LeaderbordId, (bool success) =>
{
if (success) {
((PlayGamesPlatform)Social.Active).ShowLeaderboardUI (LeaderbordId);
} else {
Debug.Log ("Add Score Fail");
}
});
}
}
public void ShowLeader ()
{
Social.ShowLeaderboardUI ();
}

I'm not sure if i got what you want. I think you are trying to open leaderboards everytime you post a score. I'll change your script to make it easier to understand.
When you are using Google Play Services Pluggin you need a few things to get started. Make sure you have this. On the top of the script you'll write:
using GooglePlayGames;
using UnityEngine.SocialPlatforms;
Then you'll need to add this to your start function:
void Start(){
PlayGamesPlatform.Activate();
}
It's easier if you make an function just to show your leaderboards, like your last function for example:
public void ShowLB(){
((PlayGamesPlatform) Social.Active).ShowLeaderboardUI("YOUR_LEADERBOARDS_ID_HERE");
}
Then your Post () function would be like this:
public void Post (){
if (Social.localUser.authenticated) {
Social.ReportScore (5000, LeaderbordId, (bool success) =>
{
if (success) {
ShowLB ();
} else {
Debug.Log ("Add Score Fail");
}
});
}
}
And it seems like in your last function you might want to do this:
public void ShowAchievs(){
Social.ShowAchievementsUI ();
}
Otherwise it should be like this:
public void ShowLB(){
((PlayGamesPlatform) Social.Active).ShowLeaderboardUI("YOUR_LEADERBOARDS_ID_HERE");
}
But it's WAY MORE EASY if you just use your post function after a trigger, like the end of the game, and use something else to show your LB. Like a click on a button or something.
I don't know that's what you wanted.

You must be running your game inside editor , You need to run your game in an actual device or perhaps an emulator ( with a gmail account ... those are rare)
Here is the thing ...
open a console , and type this
adb logcat
or you can narrow the result by filtering only logs from unity
adb logcat -s Unity
Open your game , look at at the console If you get
ShowAchievementsUI not implemented
or
ShowLeaderboardsUI not implemented
That only means that you are using the default configurations (The unity one)
I suggest you replace the defaults with google play's
The default configuration needs to be replaced with a custom configuration
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.SocialPlatforms;
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
// enables saving game progress.
.EnableSavedGames()
// registers a callback to handle game invitations received while the game is not running.
.WithInvitationDelegate(<callback method>)
// registers a callback for turn based match notifications received while the
// game is not running.
.WithMatchDelegate(<callback method>)
.Build();
PlayGamesPlatform.InitializeInstance(config);
// recommended for debugging:
PlayGamesPlatform.DebugLogEnabled = true;
// Activate the Google Play Games platform
PlayGamesPlatform.Activate();
Any errors will now be shown in the console, actually you dont need all of that of it to work , you only need these
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
for logging the errors ,
Then you can authenticate :)
If you open it and suddenly it crashes , it means that you have a problem in your manifest file
you probably going to need this if you using an older version (This get added automatically if you are using the latest version)
<application ... >
...
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
....
</application>
Make sure you update google play services to the latest one via the SDK Manager , that way you can avoid unpleasant situations
Cheers.

Related

Why is Facebook's Unity SDK Not Logging Events To Analytics?

For some reason, I am unable to get the FB.LogAppEvent to work inside an android application built with Unity.
Based on the documentation I've read, the code below should work. But it's not producing results inside the analytics dashboard. You'll notice a method that produces an Android toast that confirms activation. This toast does appear on application start. I've tried multiple event types, including custom types from code generated by Facebook's event generator in the event documentation.
https://developers.facebook.com/docs/app-events/unity
https://developers.facebook.com/docs/unity/reference/current/FB.LogAppEvent/
private void Awake()
{
if (!FB.IsInitialized)
FB.Init( () => { OnInit(); } );
else
ActivateFacebook();
}
private void OnInit()
{
if (FB.IsInitialized)
ActivateFacebook();
else
ShowAndroidToastMessage("Failed To Initialize Facebook..");
}
private void ActivateFacebook()
{
FB.ActivateApp();
ShowAndroidToastMessage("Facebook Activated..");
FB.LogAppEvent(AppEventName.ActivatedApp);
}
I suppose the problem is in the way you send event
There are two methods for that:
LogAppEvent(string logEventName);
LogAppEvent(string logEventName, float valueToSum, Dictionary parameters = null);
You are using second method with "valueToSum" = 0, and that indicates there is nothing to sum, so your event probably gets skipped at some point.
You should use the first method
FB.LogAppEvent(AppEventName.ActivatedApp);
Also make sure your analytics is enabled in dashboard.
Do you see any built in analytic events? Feg. App Launches and other Standard events should be visible out of the box.
For me, LogAppEvent(...) successfully works with the Facebook Events Tracker and Analytics when you do a development build with Unity. When I switch to a release build, I then do not get any of the LogAppEvents other than the ActivateApp() notification.
Will update my answer when I get it working with a release build.

Leaderboard not showing up - Android Native Plugin

I was using an Android Native Plugin to connect to the leaderboard. At first, I made the application to connect to the google service using
GooglePlayConnection.instance.connect();
then when a button is clicked, the function below will be called.
public void ShowLeaderboard(string leaderboardName)
{
GooglePlayManager.instance.ShowLeaderBoard("leaderboard_score");
}
The application shows the connecting to box, but when i clicked on the button to show the leaderboard, nothing happens.
Then I tried to combine the two function into one like below, but the leaderboard is not showing either. The first click will show connecting to google play service box, but the second time did not show the leaderboard.
public void LeaderboardButton(){
if(GooglePlayConnection.state == GPConnectionState.STATE_CONNECTED) {
GooglePlayManager.instance.ShowLeaderBoard("leaderboard_score");
} else{
GooglePlayConnection.instance.connect ();
}
}
I would like to know is it because of the code or because of the settings in the android native window-> edit settings?
I'm assuming you have everything in your Google Play Developer Console setup right, with that being said after reading the documentation I believe line 3 should be GooglePlayManager.instance.ShowLeaderBoardsUI("leaderboard_score");

Google authentication ERROR while trying to purchase with soomla iap

need a little help. Im making an android app and integrated Soomla for a simple "No ads" purchase inside my app. Ive a purchase button which should do the actual purchase via google.
What occurs is a popup from google : "Error
authentication needed, You have to login in your google account" .
I think its a small problem, but i dont get what. I am logged in in my google account. Store in Soomla is running ( at least it says so). ive enable test purchase.Im using my phone for the purchase ofc. What i am missing?
public class NoADsButton : MonoBehaviour {
private static bool storeInitialized = false; // prevent store to be initialized twice
void Start () {
if(storeInitialized) return;
SoomlaHighway.Initialize();
StoreEvents.OnSoomlaStoreInitialized += onSoomlaStoreInitialized;
SoomlaStore.Initialize(new SoomlaAssets());
}
public void onSoomlaStoreInitialized() {
storeInitialized = true;
}
public void OnMouseDown(){
StoreInventory.BuyItem("no_ads");
}
And the item ive done as its shown in the soomla example:
public const string NO_ADDS_PRODUCT_ID = "no_ads";
public static VirtualGood NO_ADS_LTVG = new LifetimeVG(
"No Ads", // name
"No More Ads!", // description
"no_ads", // item id
new PurchaseWithMarket(NO_ADDS_PRODUCT_ID, 0.99)); // the way this virtual good is purchased
}
This usually happens when the process of publishing the app for testing wasn't done properly. Try going carefully over Google's instructions, make sure you didn't miss anything. http://developer.android.com/google/play/billing/billing_testing.html#billing-testing-test

Chartboost Interstitial won't show Ads on Unity

Lately, I have been trying to add static interstitial ads into my Unity game. For some reason, I could not get the system to show anything, or even react to me. After trying to work with the base Chartboost plugin, I tried to match a tutorial that I was following and purchased Prime31's Chartboost plugin and have been using that. However, neither the base plugin, nor Prime31's plugin, seem to be allowing me to show any ads. The code is pretty much done inside a single object, and it seems simple enough.
public class Advertisement : MonoBehaviour {
public string chartboostAppID = "5461129ec909a61e38b1505b";
public string chartboostAppSignature = "672b3b34e3e358e7a003789ddc36bd2bc49ea3b5";
// Use this for initialization
void Start () {
DontDestroyOnLoad(this.gameObject);
ChartboostAndroid.init (chartboostAppID, chartboostAppSignature, true);
ChartboostAndroid.cacheInterstitial(null);
}
void OnLevelWasLoaded(int level) {
ChartboostAndroid.cacheInterstitial(null);
if(Application.loadedLevelName == "Network Lobby") {
showAds();
}
}
public static void showAds() {
Debug.Log("Showing ad");
ChartboostAndroid.showInterstitial(null);
}
}
As you can see, it's pretty straightforward. This object is created at the game's splash screen, which appears only once, and it's never destroyed until the program ends. The goal is, whenever I enter the lobby scene, I want to see an ad before going to the lobby's menus. As it is, I do see the log printing "Showing ad", so I know the function is being called. However, nothing appears. Do I need to disable the GUI system first? Is there a step I'm missing?
I have already performed the following steps:
I have created and registered the app with chartboost, as well as double and triple checked the AppID and App Signature.
I have created a publishing campaign and registered it to the app.
I double-checked the orientation and confirmed that it's correct.
I registered this specific device as a test device.
The tutorial showed a call to ChartBoostAndroid.OnStart(), but there was no function like that for me to call. Perhaps that is from an older version?
I emailed Chartboost support and have not heard from them yet. I do not have that much time on this project, so if anyone can offer help, I'd appreciate it.

kiip integration in android

I am trying to integrate kiip in my android app . I have downloaded the latest sdk and sample example from https://kiip.me/ developers site . Also ,I have created a new app in kiip.me site.
Everything is fine but the problem is , I am getting KPResource null so showing No Promo .
Here is the listner that I am using in onStart() method:
public void onStart() {
super.onStart();
// The Activity context has been created by now, so start a new session.
KPManager.getInstance().startSession(mStartSessionListener);
}
private KPRequestListener<KPResource> mStartSessionListener = new KPRequestListener<KPResource>() {
public void onFinished(KPManager manager, KPResource response) {
if (response != null) {
toast("Start Session Finished w/ Promo");
} else {
toast("Start Session Finished No Promo");
}
manager.showResource(response);
// Start retrieving user's location
new LocationHelper(ExampleApplication.this).requestLocationUpdates(mLocationListener);
}
Here the response is always null , so getting the message : Start Session Finished No Promo . If anyone has got similar problem then please share your views.
Thanks in advance.
Have you enabled promos for test devices in the dashboard on https://kiip.me?
It sounds like it could be a settings issue on the server side. Try logging in and switching promo frequency and adding your test device.
Finally, the issue has been resolved. I think the problem was with my device , when I tested it next day with some other device, It worked for me.

Categories

Resources