How to Use iOS GameCenter Leaderboards in Unity3d

You need to setup your app on the appstore connect first with the appropriate leaderboard. And you can only test this code on the iOS device and not in the unity3d player.


using UnityEngine.SocialPlatforms;

  private ILeaderboard leaderboard;
  private string leaderboard_id = "yourleaderboardid"; // setup on appstore connect

 void Start()
 {

    // Authenticate user first
        Social.localUser.Authenticate(success => {
            if (success)
            {
                Debug.Log("Authentication successful");
                string userInfo = "Username: " + Social.localUser.userName +
                    "\nUser ID: " + Social.localUser.id +
                    "\nIsUnderage: " + Social.localUser.underage;
                Debug.Log(userInfo);
            }
            else
                Debug.Log("Authentication failed");
        });

  // create social leaderboard
        leaderboard  = Social.CreateLeaderboard();
        leaderboard.id = leaderboard_id;
        leaderboard.LoadScores(result =>
        {
            Debug.Log("Received " + leaderboard.scores.Length + " scores");
            foreach (IScore score in leaderboard.scores)
                Debug.Log(score);
        });
  }

  void ReportScore(long score, string leaderboardID)
  {
        Debug.Log("Reporting score " + score + " on leaderboard " + leaderboardID);
        Social.ReportScore(score, leaderboardID, success => {
            Debug.Log(success ? "Reported score successfully" : "Failed to report score");
        });
  }

 void OpenLeaderboard()
 {
        Social.ShowLeaderboardUI();
 }

How To Open Chrome Device Debugger?

Last night I was trying to open the chrome debugger for an ionic app running on my ios device but could not remember the URL. This was a very simple thing but was nearly impossible to discover on the internet for some reason…

To do this: Open Chrome Browser and type chrome://inspect/ in the url field.

I don’t know why Chrome and Google make this so hard to discover.

How to Hide Specific Ionic Tabs in Angular

How to Hide Specific Ionic Tabs in Angular? It turns out ionic does not support this functionality by default although I think it should, but luckily it’s not that complicated.

Here are the 3 simple steps:

1. In your tabs.html add this ng-class

<ion-tabs ng-class="{'tabs-item-hide': hideTabs}">

</ion-tabs>

2. Add ‘hide-tabs’ in your views where you want to hide the tabs

<ion-view hide-tabs> 

</ion-view>

3. In your app.js add the directive to hide tabs

.directive('hideTabs', function($rootScope) {
    return {
        restrict: 'A',
        link: function($scope, $el) {
            $rootScope.hideTabs = true;
            $scope.$on('$destroy', function() {
                $rootScope.hideTabs = false;
            });
        }
    };
})

The hide-tabs directive will hide the tab on whichever ion-view you set it to.

iTunes Apple Music Confusing Tabs Layout

New iTunes has a lot of new problems since they added “apple music”. My biggest issue is that I don’t know which one of the main tabs I should use to search “Apple Music”. I guess there is no difference between the first 6, they all let you search for your music as well as “apple music”. But if you use “iTunes Store” tab it doesn’t let you search “apple music” or give you an explanation why.

Screen Shot 2015-07-16 at 11.02.19 PMIf it doesn’t find it in my music it should automatically search “apple music” especially since I’m a subscriber. But instead it offers me a link to search the iTunes store to purchase the music…awesome.

Screen Shot 2015-07-16 at 10.59.55 PM

If you do happen to search the store for Drake for example you’ll get to an artist page that will not let you stream the music you’re subscribed to. You have to leave and do another search on any of the other 6 tabs which you can pick randomly I guess. Also, tabs in popups? Wow. Awesome.

Screen Shot 2015-07-16 at 10.57.37 PM

If you click play on this page you only get 90 seconds of each song. Why would I wanna buy a song if I’m an apple music subscriber? Oh, to burn a CD I guess…

iPhone Nap Alarms Mess

IMG_6406

When you use Siri to set nap alarms (e.g “Wake me up in 20 min”) you end up with a new alarm for each nap. But when are you going to need an alarm for 9:01PM again? Also, you can only delete alarms one at a time. No thanks.