可允许或禁止一般推送、夜间推送、广告推送功能,可使用本地推送功能。若使用推送功能,请将广告推送设置为true(广告推送值为false时,无论是否设置一般/夜间推送,皆不会收到推送。)
import io.gamepot.common.GamePot;
import io.gamepot.common.GamePotError;
import io.gamepot.common.GamePotCommonListener;
// 允许/禁止接收推送
GamePot.getInstance().setPushEnable(/*true or false*/, new GamePotCommonListener() {
@Override
public void onSuccess() {
}
@Override
public void onFailure(GamePotError error) {
}
});
// 允许/禁止接收夜间推送
GamePot.getInstance().setNightPushEnable(/*true or false*/, new GamePotCommonListener() {
@Override
public void onSuccess() {
}
@Override
public void onFailure(GamePotError error) {
}
});
// 同时设置推送、夜间推送
// 若登录前需要确认是否允许推送、夜间推送的游戏,登录后请务必调用下列代码。
GamePot.getInstance().setPushEnable(/*true or false*/, /*true or false*/, true, new GamePotCommonListener() {
@Override
public void onSuccess() {
}
@Override
public void onFailure(GamePotError error) {
}
});
import io.gamepot.common.GamePot;
import org.json.JSONObject;
// enable: 全部推送
// night: 夜间推送
// {"enable":true, "night":true}
JSONObject status = GamePot.getInstance().getPushStatus();
String date = "2018-09-27 20:00:00";
GamePotLocalPushBuilder builder = new GamePotLocalPushBuilder(getActivity())
.setTitle("本地推送测试")
.setMessage("本地推送消息。" + date)
.setDateString(date).build();
int pushid = GamePot.getInstance().sendLocalPush(builder);
/* pushid的return值由开发者管理 */
GamePot.getInstance().cancelLocalPush(/*当前Activity*/, /*注册推送时获得的pushid*/);