gpt4 book ai didi

Show Error in OneSignal if (r.getData()) required data type boolean(如果(r.getData())需要数据类型Boolean,则在OneSignal中显示错误)

转载 作者:bug小助手 更新时间:2023-10-25 19:10:35 26 4
gpt4 key购买 nike



OneSignal.getNotifications().requestPermission(Continue.with(r -> {

if (r.isSuccess()) {
if (r.getData()) {
// `requestPermission` completed successfully and the user has accepted permission
}
else {
// `requestPermission` completed successfully but the user has rejected permission
}
}
else {
// `requestPermission` completed unsuccessfully, check `r.getThrowable()` for more info on the failure reason
}
}));

Required type: boolean
Provided: Object

How can I solve this issue while implementing OneSignal in an android studio project?

我如何在Android工作室项目中实现OneSignal时解决这个问题?


更多回答
优秀答案推荐

While my issue is somewhat different, I was having a similar issue with this part of the code when trying to get it to build for Android in my react-native project.

虽然我的问题有些不同,但当我试图在我的反应原生项目中为Android构建这部分代码时,我遇到了类似的问题。


My error was:

我的错误是:


MainApplication.java:91: error: cannot find symbol
OneSignal.getNotifications().requestPermission(Continue.with(r -> {
^
symbol: variable Continue
location: class MainApplication

The fix was to comment this block of code out entirely, as the comment above the code says:

修复方法是完全注释掉这段代码,如代码上方的注释所示:


    // requestPermission will show the native iOS notification permission prompt.
// We recommend removing the following code and instead using an In-App Message to prompt for notification permission

Unfortunately, the documentation is out of date and this comment is incorrect, as it's mentioning the "native iOS notification permission prompt."

不幸的是,文档已经过时,这条评论是不正确的,因为它提到了“本机iOS通知权限提示”。


Considering this is Android, I'm assuming this is "copy-and-paste" where they just copied and pasted big sections of code and documentation and didn't proof-read it very carefully.

考虑到这是Android,我假设这是“复制和粘贴”,他们只是复制和粘贴了大段代码和文档,并没有非常仔细地校对。


Regardless, commenting out this section allowed the android version to build. (I am using React Native).

无论如何,注释掉这一部分可以构建Android版本。(我正在使用Reaction Native)。


Or better, you could even delete the code, although you will need to figure out the correct way to prompt the user for the notification permissions.

或者更好的做法是,您甚至可以删除代码,尽管您需要找出正确的方式来提示用户输入通知权限。


Here's the original code that I commented out:

以下是我注释掉的原始代码:


   // OneSignal.getNotifications().requestPermission(Continue.with(r -> {
// if (r.isSuccess()) {
// if (r.getData()) {
// // `requestPermission` completed successfully and the user has accepted permission
// }
// else {
// // `requestPermission` completed successfully but the user has rejected permission
// }
// }
// else {
// // `requestPermission` completed unsuccessfully, check `r.getThrowable()` for more info on the failure reason
// }
// }));

更多回答

Your error should have been solved importing Continue: import com.onesignal.Continue;

您的错误本应在导入Continue时解决:导入com.onesignal.Continue;

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com