简体   繁体   English

如何将通知从Web应用发送到特定用户到移动应用

[英]How to send notification to specific user from web application to mobile application

I have a web application and mobile application to manage user parcels. 我有一个Web应用程序和移动应用程序来管理用户包裹。 Now, i want when a user receives a parcel, send a notification from web application to him on mobile application. 现在,我希望当用户收到包裹时,从Web应用程序向他在移动应用程序上发送通知。

I used OneSignal and connected my mobile app successfully, but don't know which and how call an api to send notification to specific user? 我使用了OneSignal并成功连接了我的移动应用程序,但是不知道该如何调用api以及如何调用api向特定用户发送通知?

Also, I read the documentation, but couldn't find any way and example for this requirement 另外,我阅读了文档,但找不到此要求的任何方法和示例

The most popular way to send push notification to mobile devices is by using Google Firebase push notification . 将推送通知发送到移动设备的最流行的方法是使用Google Firebase推送通知

Every device is tracked by unique device token generated by Firebase ( Android or iOS ). Firebase(Android或iOS)生成的唯一设备令牌可跟踪每个设备。

Solution for your Usecase: 您的用例解决方案:

  • Whenever user tries to login into your application just trigger an API call to backend. 每当用户尝试登录到您的应用程序时,只需触发对后端的API调用即可。

  • That API will put an entry to the database with userId and device token. 该API将使用userId和设备令牌将条目放入数据库。

  • When you going to send push notification just get the device token from the database based on userId using Firebase SDK. 当您要发送推送通知时,只需使用Firebase SDK从基于userId的数据库中获取设备令牌。

Example: 例:

To send notification for multiple device ids that may be Android or IOS. 发送有关多个设备ID(可能是Android或IOS)的通知。

You can use MulticastMessage in fireBase. 您可以在fireBase中使用MulticastMessage。

                    MulticastMessage multiCast = MulticastMessage.builder()
                        .putAllData(new HashMap<String, String>() { put("message":"hi"); })
                        .setApnsConfig(ApnsConfig.builder().build())
                        .setAndroidConfig(AndroidConfig.builder().build())
                        .addAllTokens(Arrays.asList("devicetoken1", "devicetoken2"))
                        .build();

For reference : https://firebase.google.com/docs/cloud-messaging/send-message 供参考: https : //firebase.google.com/docs/cloud-messaging/send-message

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从一个 android 应用程序向其他 android 应用程序发送通知? - How to send notification from one android application to other android application? 如何删除从移动设备清除应用程序数据后触发的通知 - how to remove notification fired after application data is cleared from mobile 如何将通知从Parse发送到Java应用程序 - How do I send a notification from Parse to a Java application 如何从云服务器向Windows桌面应用程序发送通知? - How to send notification to windows desktop application from cloud server? 从Web应用程序发送短信 - send sms from web application 如何将 Web 套接字从 Internet Web 应用程序发送到本地服务器 - How to send web sockets from an internet web application to a local server 如何在Web应用程序容器上为特定用户创建文件夹? - how to create folders for a specific user on a web application container? 使用Sinch将短信从应用程序发送到手机 - Send SMS From application to mobile using Sinch Android:将通知从php服务器发送到通知栏到android应用程序 - Android: Send a notification to notification bar from php server to android application 如何在Android应用程序中向同一应用程序的注册用户发送通知 - How to send notification to registered users of same application in android application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM