我正在关注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 Tbmp
和It's your turn in a match of Tbmp Skeleton with Player1
答案 0 :(得分:1)
原来我错过了这些界限:
class Course(db.Model):
__tablename__ = 'courses'
id = db.Column(db.Integer, primary_key=True)
course_name = db.Column(db.String, nullable=False)
course_description = db.Column(db.String, nullable=True)
course_location = db.Column(db.String, nullable=True)
start_date = db.Column(db.DateTime, nullable=True)
end_date = db.Column(db.DateTime, nullable=True)
start_time = db.Column(db.Time, nullable=True)
end_time = db.Column(db.Time, nullable=True)
max_number_students = db.Column(db.Integer, default=8)
spaces_left = db.Column(db.Integer, default=5)
is_active = db.Column(db.Boolean, default=True)
price = db.Column(db.Float, nullable=True)
def __init__(self, course_name=None, course_description=None, course_location=None,start_date=None,end_date=None,
start_time=None,end_time=None,max_number_students=None,spaces_left=None,is_active=None, price=None):
self.course_name = course_name
self.course_description=course_description
self.course_location = course_location
self.start_date = start_date
self.end_date = end_date
self.start_time = start_time
self.end_time = end_time
self.max_number_students = max_number_students
self.spaces_left = spaces_left
self.is_active = is_active
self.price = price
def __repr__(self):
return "<course name {}>".format(self.course_name)
class Purchase(db.Model):
__tablename__ = 'purchases'
uuid = db.Column(db.String, primary_key=True)
email = db.Column(db.String)
product_id = db.Column(db.Integer, db.ForeignKey('courses.id'))
payment_method = db.Column(db.String, nullable=True, default="Credit Card")
notes = db.Column(db.String, nullable=True)
date_purchased = db.Column(db.DateTime, nullable=False, default=func.now())
product = db.relationship(Course)
def __init__(self, uuid,email=None, product_id=None, product=None,payment_method=None, notes=None, date_purchased=None):
self.uuid=uuid
self.email=email
self.product_id=product_id
self.product = product
self.payment_method=payment_method
self.notes=notes
self.date_purchased=date_purchased
答案 1 :(得分:0)
(只是在这里为未来的搜索者添加一些细节到现有的答案)
您需要注册邀请/匹配更新侦听器。请参阅Games.Invitations.registerInvitationListener。
但请注意,当您的游戏未运行时,这些侦听器不会运行。在这种情况下,用户将获得系统通知。这也意味着如果您在游戏中使用这些侦听器,则系统托盘中不会显示任何通知。