【问题标题】:TBMP skeleton - How do I override notification eventsTBMP 骨架 - 如何覆盖通知事件
【发布时间】:2015-05-31 23:00:14
【问题描述】:

我正在关注 TBMP Skeleton 应用程序来创建我自己的TurnBased Multiplayer 游戏。

我尝试使用这些方法来处理通知,但它们从未被调用:

@Override
public void onInvitationReceived(Invitation invitation) {
    Toast.makeText(
            this,
            "An invitation has arrived from "
                    + invitation.getInviter().getDisplayName(), TOAST_DELAY)
            .show();
}

@Override
public void onTurnBasedMatchReceived(TurnBasedMatch match) {
    Toast.makeText(this, "A match was updated.", TOAST_DELAY).show();
}

有人知道为什么当玩家点击游戏通知时不调用这些方法吗?

另外,如果这些方法从未被调用,Google API 如何处理我收到的通知?

我的通知消息改为:Player1 invites you to a match of Skeleton TbmpIt's your turn in a match of Tbmp Skeleton with Player1

【问题讨论】:

    标签: android google-play-games multiplayer


    【解决方案1】:

    原来我错过了这些行:

    Games.Invitations.registerInvitationListener(getApiClient(), this);
    
    Games.TurnBasedMultiplayer.registerMatchUpdateListener(getApiClient(), this);
    

    【讨论】:

      【解决方案2】:

      (只是为未来的搜索者在此处为现有答案添加一些细节)

      您需要注册一个邀请/比赛更新监听器。请参阅 Games.Invitations.registerInvitationListener。

      但请注意,当您的游戏未运行时,这些侦听器不会运行。在这种情况下,用户将收到系统通知。这也意味着,如果您确实在游戏中使用了这些侦听器,系统托盘中将不会出现任何通知。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-06-22
        • 1970-01-01
        • 2021-05-06
        • 2016-06-07
        • 1970-01-01
        • 1970-01-01
        • 2011-08-26
        相关资源
        最近更新 更多