简体   繁体   English

如何从 laravel 获取设备令牌以发送推送通知?

[英]How to get the device token from laravel to send push notification?

I'm new to laravel and I want to send a push notification to my android and ios device.我是 laravel 的新手,我想向我的 android 和 ios 设备发送推送通知。 I know how to send push notification but I don't know how to get the device token.我知道如何发送推送通知,但我不知道如何获取设备令牌。

I use:"davibennun/laravel-push-notification" https://github.com/davibennun/laravel-push-notification to send pushnotification我使用:“davibennun/laravel-push-notification” https://github.com/davibennun/laravel-push-notification发送pushnotification

In your class that extends FirebaseMessagingService Service in onNewToken method send the new token to the back-end and store it in database and whenever you wan't to send notification through backend(laravel) use that token...在您的 class 中,在 onNewToken 方法中扩展 FirebaseMessagingService 服务,将新令牌发送到后端并将其存储在数据库中,每当您不想通过后端(laravel)发送通知时,请使用该令牌...

public class MyFirebaseMessagingService extends FirebaseMessagingService {

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    ...
}

@Override
public void onNewToken(@NonNull String token) {
    super.onNewToken(token);
    sendTokenToServer(token);
}
private void sendTokenToServer(String token) {
    //Send it to server using retrofit or any other lib that you're familiar with
}
}

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

相关问题 如何将简单的“推送通知”从一台设备发送到另一台设备? - How to send simple "push notification" from one device to other device? Laravel 5将推送通知发送到android和ios设备 - Laravel 5 send push notification to android and ios device 使用推送通知时如何获取用户设备令牌 - how to get the users device token when using push-notification 我们如何获得Android的设备令牌以进行推送通知? - how can we get device token for android for push notification? 推送通知的设备令牌 - Device Token for Push Notification 将android中的推送通知从设备发送到另一个 - send push notification in android from device to another Firebase推送通知如何发送到设备 - How Firebase Push Notification is send to device 如何使用解析从一个Android设备向另一个Android设备发送推送通知? - How to send push notification from one android device to another android device using parse? 如何从设备上运行的Android应用程序向另一个运行相同应用程序的设备发送推送通知? - how to send a push notification from an android app running on a device to another device running the same app? 当接收方设备未在Android中使用FCM处于前台状态时,如何从设备发送推送通知? - How to send Push Notification from device when the receiver device is not in foreground state using FCM in android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM