Laravel 5 向 android 和 ios 设备发送推送通知

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32234352/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:15:48  来源:igfitidea点击:

Laravel 5 send push notification to android and ios device

androidioslaravelpush-notificationgoogle-cloud-messaging

提问by Rai

I took the package

我拿了包裹

I set up on the instructions. I decided to test to do so

我按照说明设置。我决定测试这样做

$token = DeviceToken::find($id);
    $deviceToken = $token->device_token;
    PushNotification::app('appNameAndroid')
        ->to($deviceToken)
        ->send('Hello World, i`m a push message');

but it gives an error 401 Forbidden; Authentication Error

但它给出了错误 401 Forbidden; 授权错误

in what could be the problem? help a problem in the device token? What length should be the device token?

可能是什么问题?帮助设备令牌中的问题?设备令牌的长度应该是多少?

采纳答案by Koh

This is not an issue with the device token but rather an issue with your server's API key. Refer to the 401 error definition and recommended action here.

这不是设备令牌的问题,而是您服务器的 API 密钥的问题。请参阅此处的 401 错误定义和建议的操作。

This usually happens when you have an API key but have not enabled the "Google Cloud Messaging for Android" API in the Developers Console.

当您拥有 API 密钥但尚未在开发人员控制台中启用“Android 版 Google Cloud Messaging”API 时,通常会发生这种情况。