können Sie den Wert in userId
stellen Sie sicher, ein gültiges OneSignal ID auf Ihrem Konto ist und es abonniert ist?
Sie können auch den folgenden Code verwenden, um Logcat-Logging hinzuzufügen, um das Problem zu debuggen.
try {
OneSignal.postNotification(new JSONObject("{'contents': {'en':'Test Message'}, 'include_player_ids': ['" + "userId" + "']}"),
new OneSignal.PostNotificationResponseHandler() {
@Override
public void onSuccess(JSONObject response) {
Log.i("OneSignalExample", "postNotification Success: " + response.toString());
}
@Override
public void onFailure(JSONObject response) {
Log.e("OneSignalExample", "postNotification Failure: " + response.toString());
}
});
} catch (JSONException e) {
e.printStackTrace();
}