Firebase 消息推送通知在桌面和 Android 网络浏览器上没有任何问题,但是当我在 IOS 设备上测试它时,我使用哪个浏览器并不重要,通知和 .getToken() 方法不起作用。我的 JavaScript 代码是:
if ('Notification' in window) {
var messaging = firebase.messaging();
if (Notification.permission === 'granted') {
subscribe();
}
$('#notify').on('click', function () {
subscribe();
});
}
function subscribe() {
// ??????????? ?????????? ?? ????????? ???????????
messaging.requestPermission()
.then(function () {
// ???????? ID ??????????
return messaging.getToken()
.then(function (currentToken) {
console.log(currentToken);
if (currentToken) {
sendTokenToServer(currentToken);
} else {
console.warn('?? ??????? ???????? ?????.');
setTokenSentToServer(false);
}
})
.catch(function (err) {
console.warn('??? ????????? ?????? ????????? ??????.', err);
setTokenSentToServer(false); …Run Code Online (Sandbox Code Playgroud) push-notification apple-push-notifications firebase firebase-cloud-messaging
我使用 laravel/passport 进行 api 身份验证。我的问题是,当我想通过 Postman 在本地主机上注册为新用户时,一切正常,但实时服务器上的相同代码返回如下所示的内容:
尝试获取非对象“异常”的属性:“ErrorException”,“文件”:“/vendor/laravel/passport/src/ClientRepository.php”,“line”:89,
我的用户注册代码如下:
$user = User::create([
'name' => $request->name,
'email' => $request->email,
'password' => bcrypt($request->password),
'phone_number' => $request->phone_number,
]);
$success['name'] = $user->name;
$success['token'] = $user->createToken('Test')->accessToken;
return response()->json(['success' => $success], 200);
Run Code Online (Sandbox Code Playgroud)