OneSignal postNotification Android
•
Android
My native application requires postnotification in Android
I have this code, but it doesn't work:
try { OneSignal.postNotification(new JSONObject("{'contents': {'en':'Test Message'}, 'include_player_ids': ['" + userId + "']}"), null); } catch (JSONException e) { e.printStackTrace(); }
@H_403_9@解决方法:
您可以确定userId中的值是您帐户上的有效OneSignal ID并已订阅吗?
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(); }
@H_403_9@总结
以上是编程之家为你收集整理的OneSignal postNotification Android全部内容,希望文章能够帮你解决OneSignal postNotification Android所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码