Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toast not shown in Honor 8XS #120

Closed
3 of 7 tasks
Jeijie opened this issue Sep 25, 2018 · 14 comments
Closed
3 of 7 tasks

Toast not shown in Honor 8XS #120

Jeijie opened this issue Sep 25, 2018 · 14 comments

Comments

@Jeijie
Copy link

Jeijie commented Sep 25, 2018

Expected behaviour

show Toast

Actual behaviour

Toast not shown in Honor 8X

I'm seeing this behaviour on

  • iOS device
  • iOS sim
  • Android device
  • Android sim

Hardware models

Honor 8X
Android 8.1.0

OS versions

ExCordova CLI: 6.5.0
Ionic Framework Version: 1.2.4
Ionic CLI Version: 2.1.4
Ionic App Lib Version: 2.1.2
OS: Windows 7 SP1
Node Version: v10.8.0

I'm not a dummy, so I've checked these

  • It happens on a fresh Cordova CLI project as well.
  • I'm waiting for deviceready to fire.
  • My JavaScript has no errors (window.onerror catches nothing).
@DGGohil
Copy link

DGGohil commented Oct 5, 2018

Remove this line from your index.html file meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;"> and add below one..
...
meta http-equiv="Content-Security-Policy" content="default-src * gap: ws: https://ssl.gstatic.com;style-src * 'unsafe-inline' 'self' data: blob:;script-src * 'unsafe-inline' 'unsafe-eval' data: blob:;img-src * data: 'unsafe-inline' 'self' content:;media-src mediastream;">

@zhzhch335
Copy link

Try subscribe it with empty even:
this.toast.showShortCenter("再次点击返回键退出").subscribe();
In my project it works.
BTW my device is Honor V10.
I don't know its reason....

@DGGohil
Copy link

DGGohil commented Oct 22, 2018

I do have Honor V10 and i didn/t tried with .subscribe() , mine worked by doing above method.

@NorthFred
Copy link

NorthFred commented Oct 28, 2018

It seems that the toast notifications do not show on Android 8+ when using the latest versions of the plugin.

I removed the latest plugin from my project and went back to 2.5.2, and the toasts are working on at least Android 8.0 (e.g. Huawei P Smart) and Android 8.1 (Honor 7S).

ionic cordova plugin rm cordova-plugin-x-toast
ionic cordova plugin add cordova-plugin-x-toast@2.5.2

@Jeijie
Copy link
Author

Jeijie commented Oct 30, 2018

@NorthFred It no works in Honor 8X,Android 8.1.0

@Jeijie
Copy link
Author

Jeijie commented Oct 30, 2018

@DGGohil I had tried with .subscribe() , but it no worked by doing above method.

@DGGohil
Copy link

DGGohil commented Oct 30, 2018

@DGGohil I had tried with .subscribe() , but it no worked by doing above method.

PM me your index.html.

@Jeijie
Copy link
Author

Jeijie commented Oct 30, 2018

@DGGohil

Whether or not there is a sentence above. It doesn't work.

meta charset="utf-8"
meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width, viewport-fit=cover"

meta http-equiv="Content-Security-Policy" content="default-src * gap: ws: https://ssl.gstatic.com;style-src * 'unsafe-inline' 'self' data: blob:;script-src * 'unsafe-inline' 'unsafe-eval' data: blob:;img-src * data: 'unsafe-inline' 'self' content:;media-src mediastream;"

@aoilti
Copy link

aoilti commented Nov 8, 2018

I also encountered this problem, and my device is Xiaomi 8, Android 8.1

@Jeijie
Copy link
Author

Jeijie commented Nov 9, 2018

I also integrated cordova-plugin-toastyplugin to my project, it works for me.

if (window.cordova&&window.plugins.toastyPlugin) {
window.plugins.toastyPlugin.show(message, 1000, function () {
console.log('totoastyPluginast success');
}, function () {
});
}else if (window.cordova&&window.plugins.toast) {
window.plugins.toast.showShortCenter(message, function (res) {
console.log('toast success');
}, function () { });
} else {
alert(message);
}

@aoilti
Copy link

aoilti commented Nov 9, 2018

I also integrated cordova-plugin-toastyplugin to my project, it works for me.

if (window.cordova&&window.plugins.toastyPlugin) {
window.plugins.toastyPlugin.show(message, 1000, function () {
console.log('totoastyPluginast success');
}, function () {
});
}else if (window.cordova&&window.plugins.toast) {
window.plugins.toast.showShortCenter(message, function (res) {
console.log('toast success');
}, function () { });
} else {
alert(message);
}

Are you talking about ToastyPlugin? I installed it, but I saw that the source code inside it is not very reliable, actually there is alert
image

@Jeijie
Copy link
Author

Jeijie commented Nov 9, 2018

@Zhang1051127659

Yeah!, same issue I encountered , you need remove it manually and install again.
image

@442623641
Copy link

it work for me:
Toast.java, find
private static final boolean IS_AT_LEAST_PIE = Build.VERSION.SDK_INT >= 28;
replace with
private static final boolean IS_AT_LEAST_PIE = Build.VERSION.SDK_INT >= 26;

@EddyVerbruggen
Copy link
Owner

Published 2.7.1 which removes the problematic code entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants