- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在将 react-native-device-info 从 v2 迁移到 v3,并且我有一个重大变化。在更新软件包之前,一切正常。该错误出现在所有模拟器和真实设备上。
我得到的错误是:
NativeFirebaseError: [messaging/unregistered] You must be registered for remote notifications before calling get token, see messaging().registerForRemoteNotifications() or requestPermission().
System:
OS: macOS 10.15.4
CPU: (8) x64 Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
Memory: 6.44 GB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.14.0 - ~/.nvm/versions/node/v12.14.0/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.13.4 - ~/.nvm/versions/node/v12.14.0/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.3
System Images: android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6241897
Xcode: 11.4.1/11E503a - /usr/bin/xcodebuild
npmPackages:
react: 16.12.0 => 16.12.0
react-native: 0.61.5 => 0.61.5
npmGlobalPackages:
create-react-native-app: 2.0.2
react-native-cli: 2.0.1
react-native-debugger-open: 0.3.24
export interface LoginParams {
token?: string;
useProduct?: string;
useUser?: string;
ssoToken?: string;
}
// TODO: Should be switched out with tv-ui-common once the whole app starts using Product model.
interface AuthenticationResponse {
noCacheToken: string;
products: ProductData[];
currentUserId: number;
}
interface ProductsResponse {
currentProductCode: string;
products: ProductData[];
}
const getInitialIsLoggedIn = () => false;
const getInitialAuthenticating = () => false;
const getInitialProducts = () => [];
const getInitialSelectedProduct = () => null;
const getInitialCurrentUserId = () => null;
export default class AuthenticationStore {
private static async authenticate({ token, useProduct, useUser, ssoToken }: LoginParams) {
const params = new URLSearchParams();
params.append('ui', UI);
params.append('uuid', DeviceInfo.getUniqueId());
params.append('model', DeviceInfo.getSystemName());
params.append('hwVersion', DeviceInfo.getModel());
params.append('swVersion', DeviceInfo.getSystemVersion());
params.append('uiVersion', getUiVersion());
if (useProduct) {
params.append('useProduct', useProduct);
}
if (useUser) {
params.append('useUser', useUser);
}
try {
const notificationToken = await messaging().getToken();
params.append('pushToken', notificationToken);
console.log(notificationToken, 'notificationToken');
} catch (error) {
// iPhone Simulator does not give a token
console.log("error", error);
}
try {
// If we have token, meaning user authenticated via TV pairing
if (token) {
params.append('token', token);
return await Api.post<AuthenticationResponse>(
'authentication/token',
params.toString(),
undefined,
'3.0',
);
}
if (ssoToken) {
params.append('ssoToken', ssoToken);
}
return await Api.post<AuthenticationResponse>(
'authentication/sso',
params.toString(),
undefined,
'3.0',
);
} catch (error) {
console.log('err', error);
if (error.response.status === 423) {
throw new ProductNotAvailableError(error.response.data.products);
} else {
throw error;
}
}
}
@observable public isLoggedIn = getInitialIsLoggedIn();
@observable public authenticating = getInitialAuthenticating();
@observable public products: ProductData[] = getInitialProducts();
@observable public selectedProduct: ProductData | null = getInitialSelectedProduct();
@observable public currentUserId: number | null = getInitialCurrentUserId();
constructor() {
this.registerPushNotificationToken = this.registerPushNotificationToken.bind(this);
this.loadProducts = this.loadProducts.bind(this);
}
@action public reset() {
this.isLoggedIn = getInitialIsLoggedIn();
this.authenticating = getInitialAuthenticating();
this.products = getInitialProducts();
this.selectedProduct = getInitialSelectedProduct();
this.currentUserId = getInitialCurrentUserId();
}
public async registerPushNotificationToken(token: string) {
if (this.isLoggedIn) {
await Api.post('push-token-update', { token }, undefined, '3.0');
}
}
public async login(params: LoginParams = {}): Promise<boolean> {
this.setAuthenticating(true);
try {
const response = await AuthenticationStore.authenticate(params);
setNoCacheToken(response.data.noCacheToken);
const products = response.data.products || [];
this.setProducts(products);
if (response.status === 202) {
if (products.length === 1) {
const [product] = products;
return this.login({ useProduct: product.code });
}
if (products.length > 1) {
throw new ProductNotSelectedError();
}
}
this.setSelectedProduct(products[0]);
this.setAuthenticating(false, true, response.data.currentUserId);
analytics().setUserId(response.data.currentUserId.toString());
} catch (error) {
this.setAuthenticating(false, false);
if (error.response && error.response.status === 401) {
if (error.response.data.errorCode === 'E_UNAUTHORIZED') {
// Silently fail error if user was not authenticated while doing sso request.
// We do not need to handle that 'error'. It's common case for cookies
// to expire.
return false;
}
throw new NoProductsError();
}
if (
(error.response && error.response.status === 400)
|| error instanceof ProductNotSelectedError
) {
throw error;
} else if (error instanceof ProductNotAvailableError) {
// Product is suspended or in debt and thus not usable
const selectedProduct = error.products.find(
product => product.code === params.useProduct,
);
this.setProducts(error.products, selectedProduct);
throw error;
} else {
// Something went wrong with authentication on server side.
throw new Error(`Unexpected authentication error: ${error}`);
}
}
return this.isLoggedIn;
}
public async loadProducts() {
try {
// Logged in version of fetching products
const { data: { products, currentProductCode } } = await Api.get<ProductsResponse>('products');
const selectedProduct = products.find(product => product.code === currentProductCode);
this.setProducts(products, selectedProduct);
} catch (error) {
if (error.response.status === 401) {
// Logged out version of fetching products
try {
const response = await AuthenticationStore.authenticate({});
const products = response.data.products || [];
this.setProducts(products);
} catch (loginError) {
// TODO: Handle error
}
}
// TODO: Handle failed request on loading products
}
}
@action public setAuthenticating(
authenticating: boolean = false,
isLoggedIn: boolean = this.isLoggedIn,
currentUserId: number | null = this.currentUserId,
) {
this.authenticating = authenticating;
this.isLoggedIn = isLoggedIn;
this.currentUserId = this.isLoggedIn ? currentUserId : null;
}
@action private setProducts(
products: ProductData[],
selectedProduct: ProductData | null = null,
) {
this.products = products;
this.setSelectedProduct(selectedProduct);
}
@action private setSelectedProduct(product: ProductData | null = null) {
this.selectedProduct = product;
}
}
最佳答案
该错误表示您需要在调用 getToken 之前向用户请求通知权限。你试过这个吗? https://rnfirebase.io/messaging/usage
关于javascript - 如何解决与 react-native-device-info 相关的 React Native Firebase 错误 (messaging().getToken()),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61790192/
我尝试将 python 2.x 代码移植到 python 3。我正在努力解决的问题是 from mimetools import Message ... headers = Message(Strin
我有一个输入组件,它有三种类型的验证(required、validatorMessage、converterMessage),这个输入有自己的消息图标,整个表单有一个消息组件来显示所有组件的所有消息,
我有一个使用消息代理 (activemq) 的带有 spring 和 websockets 的 webapp。 这是我的配置类: @Configuration @EnableWebSocketMess
据我了解mbox Python 3.6 标准库中的类生成 email.message.Message 类型的旧式消息对象. 较新的类(class) email.message.EmailMessage
我使用的是mysql。 我有一个包含 userid、message_id、opened(true 或 false)、时间戳的消息表。 我希望所有未打开最近收到的 5 条消息的用户 这就是我现在拥有的:
我是 Android 的新手,发现要不断更新主视图,我必须创建一个线程来处理各种进程,然后将更新传回主视图。我决定使用 Handler 类来执行此操作。此示例中的 View 有一个用于激活代码的按钮和
我遇到了重定向符号的不同位置( > , &2 message message echo message >&2 message >&2 echo message message 对于所有表单,我得到了
我想使用 firebase 云函数发送通知,所以我尝试使用 firebase.messaging().getToken() 获取 token ,但我不断收到错误消息: TypeError: fireb
我实现了一个短信应用。现在我在使用 Oppo 设备时遇到了问题,因为无论何时收到消息,系统都会将默认应用程序更改为内置应用程序并显示此消息: For your messages security, S
我正在实现本指南:https://spring.io/guides/gs/centralized-configuration/关于Spring Cloud配置。 服务器: @EnableConfigS
我想在“匹配”之后,向所有比赛发送介绍信息。你知道一种轻松发送的方法吗?(我使用 Bluestacks) 提前致谢。问候。 最佳答案 只需传递 session.send()在session.dialo
在我们的应用程序中,我们使用 kafka 并有一个像这样的 Spring Cloud 输入流 @Component public interface SomeChannel { @Input(
这周我在通过 Node.js 库(代码相同,库版本相同等)向我的 iOS 设备发送消息时遇到了很多内部错误 很难调试,因为有时它会起作用。当我使用 for 循环发送 10 条消息时,我的设备将收到 3
我目前正在记录错误并希望获得尽可能多的描述性细节。我知道我可以捕获许多不同类型的异常,但 Exception.Message 之间有什么区别?和 Exception.InnerException.Me
我创建了一个映射到 MyBean.beansField 的表单。我使用 javax.validation.NotNull 注释来确保必须输入它。到目前为止一切正常,但错误消息如下所示: beansFi
我正在研究 Azure 服务总线。我的服务总线队列正在处理一条消息 3 次。我的消息锁定时间是5分钟。每条消息最多处理 2 分钟,但我不知道为什么队列会选择相同的消息并发送到处理,而重复的消息仅在 5
我正在使用最新的快速修复版本,即 1.6.0。我已经有针对 1.5.3 编写的代码,我想做的是将其升级到 1.6.0 我遇到的问题是,当我使用破解(msg,sessionID)方法时,它会抛出quic
当我调用 grails message()函数来查找和评估消息 key 对,它无法评估参数。 在我的 Controller 中,我调用消息函数: rejectWithError(message(cod
我使用一个小型 Spring 应用程序,其中数据库中的值很少,我想使用可变调用来检索它们。 API 在这里, @RestController @RequestMapping("/api/v1/prod
我在想在用以更好的方式,像这样: Please inform us about: 这个想法是以一种不同的方式向用户展示消息,具有更多的风格。这可能吗? 最佳答案 它们可通过 Fac
我是一名优秀的程序员,十分优秀!