Gamecenter plugin

This plugins allows you to access apple gamecenter

Platforms:

iOS, tvOS, macOS

Limitations:

tvOS does not support getting friends and also leaderboard.show will show achievements(I recommend making your own interface).

Functions:

gc.init(listener)

handles sign in and connection status

  • type(string)--"login"
    • status(string)-- "signed in", "could not login", "showing login", or "could not access gamecenter"
  • type(string)--"error"
    • status(string)-- "error" or "other error"
    • error(string)-- "feature not available", "unable to access gamecenter", "unknown error", "internet not available", or if "other error" you will get a description of error

gc.isAvailable() -- returns(boolean) true is gamecenter is available and false if not available

Nodes:

  • gc.leaderboards -- handles gamecenter leaderboards
    • gc.leaderboards.show("leaderboardId") --returns "showing"
    • leaderboardId (string)(optional) If this is nil or blank, it will show all leaderboards. If it is a string, it will show that leaderboard based on the id
    • gc.leaderboards.loadScores("leaderboardId", listener,{params}) --returns "showing"
    • leaderboardId (string) the id of leaderboard that you want to get scores from
    • listener (function)
      • status(string)-- can be "success" or "error"
      • error(string)-- explains the error
      • scores(array) each array contains table:
        • date(string)-- returns date of score ("HH:mm yyyy/MMM/d")(timezone GMT)
        • leaderboardIdentifier(string)-- leaderboardId of the leaderboard requested
        • rank(integer)-- how high the person is ranked on the the leaderboard
        • playerId(string)-- id of player who got the score
        • value(integer)-- the actual score
        • playerAlias(string)--username of player
        • formattedValue(string)--A player’s score as a localized string. You determine how your scores are formatted when you define the leaderboard on iTunes Connect.
    • params (table)(optional)
    • insert these values in table:
      • timeScope(string)-- possible values are "today", "week", or "all"(all is default)
      • playerScope(string)-- possible values are "friends" or "global"(global is default)
      • rangeMin(integer)-- the starting number to start getting scores from a leaderboard(requires rangeMax and only can get up to 100 values)
      • rangeMax(integer)-- the ending number to stop getting scores from a leaderboard(requires rangeMin and only can get up to 100 values)
      • rangeMax(integer)-- the ending number to stop getting scores from a leaderboard(requires rangeMin and only can get up to 100 values)
    • gc.leaderboards.loadScore("leaderboardId", listener) --returns (integer) your score from a leaderboard
    • leaderboardId (string) the id of leaderboard that you want to get the signed users score from
    • listener (function)
      • status(string)-- can be "success" or "error"
      • error(string)-- explains the error
      • score(integer) score of player
    • gc.leaderboards.submit("leaderboardId", score.0, listener)
    • leaderboardId (string) the id of leaderboard that you want to get the signed users scores from
    • score(integer) the score to be sent
    • listener(function)
      • status(string)-- either "score sent" or "error"
      • error(string)-- explains the error

  • gc.achievements -- handles gamecenter achievements
    • gc.achievements.show() --returns "showing"
    • show the achievement gamecenter popup
    • gc.achievements.loadAll(listener)
    • returns all the achievements
    • listener (function)
      • status(string)-- can be "success" or "error"
      • error(string)-- explains the error
      • achievements(array) each array contains table:
        • lastReportedDate(string)-- The last time that progress on the achievement was successfully reported to Game Center.("HH:mm yyyy/MMM/d")(timezone GMT)
        • percentComplete(interger)-- leaderboardId of the leaderboard requested (1-100)
        • identifier(string)-- the id of the achievement
        • unachievedDescription(string)-- A localized description of the achievement to be used when the local player has not completed the achievement.
        • title(string)-- title of achievement
        • achievedDescription(string)--A localized description to be used after the local player has completed the achievement.
        • status(string)-- either "hidden" or "visible"
        • replayable(string)-- either "replayable" or "not replayable"
    • gc.achievements.submit("achievementId", progress.0, listener)
    • achievementId (string) the id of achievement that you want to send the signed users progress on
    • progress(integer) the progress to be sent should be between 1-100
    • listener(function)
      • status(string)-- either "achievement set" or "error"
      • error(string)-- explains the error
    • gc.achievements.reset(listener)
    • resets all achievements immediately
    • listener(function)
      • status(string)-- either "success" or "error"
      • error(string)-- explains the error
  • gc.challenges -- handles gamecenter challenges
    • gc.challenges.show() --returns "showing"
    • show the challenges gamecenter popup
    • gc.challenges.load(listener)
    • returns all the challenges
    • listener (function)
      • status(string)-- can be "success" or "error"
      • error(string)-- explains the error
      • challenges(array) each array contains table:
        • issuingPlayerId(string)-- the playerid of the who sent the challenge
        • issuingPlayerAlias(string)-- the player name of the who sent the challenge
        • receivingPlayerId(string)-- the id of the player who received
        • receivingPlayerAlias(string)-- the name of the player who received
        • state(string)-- state of challenge: "declined", "complete", "pending", or "invalid"
        • message(string)--the message sent with a challenge
        • issueDate(string)-- the date the challenge was sent ("HH:mm yyyy/MMM/d")(timezone GMT)
        • completionDate(string)-- The date the challenge was completed ("HH:mm yyyy/MMM/d")(timezone GMT)

  • gc.player -- handles player data
    • gc.player.id() (string) --returns the gamecenter id
    • gc.player.name() (string) --returns the gamecenter username
    • gc.player.underage() (boolean) --returns a boolean value that indicates whether the local player is underage
    • gc.player.multiplayerGamingRestricted() (boolean) --(iOS 13+)returns a Boolean value that indicates whether the player can join multiplayer games.
    • gc.player.friends(listener)
    • listener(function)
      • status(string)-- can be "success" or "error"
      • error(string)-- explains the error
      • friends(array) -- returns array of tables which contain playerID(string) and displayName(string)

  • gc.multiplayer -- handles multiplayer
    • gc.multiplayer.invite(minPlayers, maxPlayers, inviteMessage, showExistingMatches ,listener, recipients) --invite a new player and show existing matches
    • minPlayers(optional)(integer) the minimum number of players
    • maxPlayers(optional)(integer) the max number of players
    • inviteMessage(optional)(string) The string displayed on another player’s device when invited to join a match
    • showExistingMatches(optional (default is true))(boolean) if true the UI will show existing matches
    • listener (function)
      • status(string)-- can be "finish", "foundMatch","playerDidQuitForError", "playerDidQuit", "finish", "cancelled", or "error"
      • creationDate(string)-- date of match creation
      • matchID(string)-- matchID
      • itIsMyTurn(boolean)-- boolean for whether it is your turn or not
      • error(string)-- error when status is "error"
    • recipients(optional)(array of strings) put player IDs in here
    • gc.multiplayer.newMatch(minPlayers, maxPlayers, inviteMessage, recipients, listener) --create match without using native UI
    • minPlayers(optional)(integer) the minimum number of players
    • maxPlayers(optional)(integer) the max number of players
    • inviteMessage(optional)(string) The string displayed on another player’s device when invited to join a match
    • recipients(optional)(array of strings) put player IDs in here
    • listener (function)
      • status(string)-- can be "finish", "foundMatch","playerDidQuitForError", "playerDidQuit", "finish", "cancelled", or "error"
      • creationDate(string)-- date of match creation
      • matchID(string)-- matchID
      • itIsMyTurn(boolean)-- boolean for whether it is your turn or not
      • error(string)-- error when status is "error"
    • gc.multiplayer.setListener(listener)-- Set Listener for multiplayer callbacks
    • listener (function)
      • status(string)-- can be "exchangeCancellation", "receivedExchangeReplies","receivedExchangeRequest", "requestMatchWithOtherPlayer", "matchEnded", "receivedTurnEventForMatch", or "playerWantsToQuit"
      • participants(array)-- contatins table which contain playerOutcome(string)(can be "won", "lost", "quit", "tied", "first", "second", "third", "fourth", "timeExpired", "customRange", "none") ,displayName(string), playerID(string)
      • message(string)-- match message
      • message
      • matchID(string)-- matchID
      • itIsMyTurn(boolean)-- boolean for whether it is your turn or not
      • didBecomeActive(boolean)-- when status == "receivedTurnEventForMatch"
      • playerName(string)-- the name of player for the event
      • playerID(string)-- the id of player for the event
      • activeExchanges(table)-- contatins data(table), message(string), displayName(string), playerID(string)
      • playersToInvite(table)-- contatins displayName(string), playerID(string)
      • matchData(table)-- table of match data
      • error(string)-- error when status is "error"
      • currentParticipantDisplayName(string)-- Current Player Display Name
      • currentParticipantID(string)-- Current Player PlayerId/gamePlayerID
    • gc.multiplayer.getMatchData(listener)
    • listener(function)
      • status(string)-- can be "gotMatchData", "matchNotActive", or "error"
      • participants(array)-- contatins table which contain playerOutcome(string)(can be "won", "lost", "quit", "tied", "first", "second", "third", "fourth", "timeExpired", "customRange", "none") ,displayName(string), playerID(string)
      • currentParticipantDisplayName(string)-- Current Player Display Name
      • currentParticipantID(string)-- Current Player PlayerId/gamePlayerID
      • error(string)-- explains the error
      • matchID(string) -- matchID
      • data(table) -- data from match
    • gc.multiplayer.getMatchStatus(listener)
    • listener(function)
      • status(string)-- can be "open", "matching", "matchNotActive", or "ended"
    • gc.multiplayer.updateData(data,listener)
    • data(table)-- data to update
    • listener(function)
      • status(string)-- "dataUpdated" or "error"
      • error(string)-- explains the error
    • gc.multiplayer.deleteMatch(matchId,listener)
    • matchId(string (optional will delete active match if nil))-- matchId to delete match
    • listener(function)
      • status(string)-- "matchDeleted" or "error"
      • error(string)-- explains the error
    • gc.multiplayer.quitOutOfTurn(outcome,listener)
    • outcome(string)(optional default "none") -- can be "won", "lost", "quit", "tied", "first", "second", "third", "fourth", "timeExpired", "customRange", or "none"
    • listener(function)
      • status(string)-- "quitOutOfTurn" or "error"
      • error(string)-- explains the error
    • gc.multiplayer.quitInTurn(outcome, turnTimeout, data, listener)
    • outcome(string)(optional default "none") -- can be "won", "lost", "quit", "tied", "first", "second", "third", "fourth", "timeExpired", "customRange", or "none"
    • turnTimeout(integer)-- number of seconds before a players turn is skipped
    • data(table)-- data quit in turn with
    • listener(function)
      • status(string)-- "quitInTurn", "matchNotActive", or "error"
      • error(string)-- explains the error
    • gc.multiplayer.endTurn(data, turnTimeout, listener)
    • data(table)-- data to end turn
    • turnTimeout(integer)-- number of seconds before a players turn is skipped
    • listener(function)
      • status(string)-- "turnEnded", "matchNotActive", or "error"
      • error(string)-- explains the error
    • gc.multiplayer.endMatch(data, listener)
    • data(table)-- data to end match
    • listener(function)
      • status(string)-- "endMatch", "matchNotActive", or "error"
      • error(string)-- explains the error
    • gc.multiplayer.isItMyTurn(listener)
    • data(table)-- data to end match
    • listener(function)
      • status(string)-- can be "matchNotActive", "notMyTurn", "itIsMyTurn"
      • playerName(string)-- the name of player for the event
      • playerID(string)-- the id of player for the event
    • gc.multiplayer.listMatches(listener)
    • listener(function)
      • isError(boolean)
      • error(string)-- explains the error
      • matches(array)--contains array of tables which has matchID(string), creationDate(string which in HH:mm yyyy/MMM/d format), matchData(table), and participants(array)-- contatins table which contain playerOutcome(string)(can be "won", "lost", "quit", "tied", "first", "second", "third", "fourth", "timeExpired", "customRange", "none") ,displayName(string), playerID(string), currentParticipantDisplayName(string), currentParticipantID(string)
    • gc.multiplayer.startMatchWithId(matchId,listener)
    • matchId(string)
    • listener(function)
      • status(string) -- can be "error" or "startedMatchWithId"
      • participants(array)-- contatins table which contain playerOutcome(string)(can be "won", "lost", "quit", "tied", "first", "second", "third", "fourth", "timeExpired", "customRange", "none") ,displayName(string), playerID(string)
      • error(string)-- explains the error
      • itIsMyTurn(boolean)-- boolean for whether it is your turn or not
      • matchData(table)-- table of match data
    • gc.multiplayer.rematch(listener) -- rematch current game
    • listener(function)
      • status(string) -- can be "error" or "rematchStarted"
      • participants(array)-- contatins table which contain playerOutcome(string)(can be "won", "lost", "quit", "tied", "first", "second", "third", "fourth", "timeExpired", "customRange", "none") ,displayName(string), playerID(string)
      • error(string)-- explains the error
      • itIsMyTurn(boolean)-- boolean for whether it is your turn or not
      • currentParticipantDisplayName(string)-- Current Player Display Name
      • currentParticipantID(string)-- Current Player PlayerId/gamePlayerID
      • matchData(table)-- table of match data
    • gc.multiplayer.sendReminderToAllParticipants(localizableMessageKey, arguments, listener) -- send a reminder to all participants
    • localizableMessageKey(string)
    • arguments(array of strings)
    • listener(function)
      • status(string) -- can be "error" or "reminderSent"
    • gc.multiplayer.sendReminderToParticipantWithId(participantId, localizableMessageKey, arguments, listener) -- send a reminder to participant with Id
    • participantId(string) -- the id of participant(either PlayerId or gamePlayerID)
    • localizableMessageKey(string)
    • arguments(array of strings)
    • listener(function)
      • status(string) -- can be "error", "playerNotFound", or "reminderSent"
    • gc.multiplayer.listParticipants(listener) -- list participants
    • listener(function)
      • status(string)-- can be "gotParticipants", "matchNotActive", or "error"
      • participants(array)-- contatins table which contain playerOutcome(string)(can be "won", "lost", "quit", "tied", "first", "second", "third", "fourth", "timeExpired", "customRange", "none") ,displayName(string), playerID(string)
      • currentParticipantDisplayName(string)-- Current Player Display Name
      • currentParticipantID(string)-- Current Player PlayerId/gamePlayerID
      • error(string)-- explains the error
    • gc.multiplayer.setMatchOutcome(participantId,listener) -- list participants
    • participantId(string) -- the id of participant(either PlayerId or gamePlayerID)
    • listener(function)
      • status(string)-- can be "outcomeSet", "matchNotActive", or "playerNotFound"
    • gc.accessPoint -- handles gamecenter access point for iOS 14+
      • gc.accessPoint.setActive(shouldEnable)
      • shouldEnable(boolean) -- A Boolean value that determines whether to display the access point
      • gc.accessPoint.setLocation(location)
      • location(string) -- location of access point icon "bottomLeading", "bottomTrailing","topLeading", or "topTrailing"
      • gc.accessPoint.setShowHighlights(shouldEnable)
      • shouldEnable(boolean) -- A Boolean value that indicates whether to display highlights for achievements and current ranks for leaderboards.
      • gc.accessPoint.setFocused(shouldFocus)
      • shouldFocus(boolean) -- only tvOS, A Boolean value that indicates whether the access point is in focus on tvOS.
      • gc.accessPoint.triggerAccessPoint() -- Displays the Game Center dashboard
      • gc.accessPoint.triggerAccessPointWithType(accessPointType) -- Displays the Game Center dashboard in the specified state
      • accessPointType(string) -- can be "default", "leaderboards","achievements", "challenges", "localPlayer", or "dashboard"

      Build Settings:

      Helpful links:

      Get Plugin

      Example

      Support