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

Notification makes a sound but does not show any text #7

Open
jondspa opened this issue Jan 30, 2023 · 1 comment
Open

Notification makes a sound but does not show any text #7

jondspa opened this issue Jan 30, 2023 · 1 comment

Comments

@jondspa
Copy link

jondspa commented Jan 30, 2023

WARNING: IF YOU IGNORE THIS TEMPLATE, WE'LL IGNORE YOUR ISSUE. YOU MUST FILL THIS IN!

Android - Notification is triggered. Device makes a sound. I can see the notification text in the notification center. But no the notification text does not show on the screen.

I've been using this great plugin for a while, trying to update to SDK API 31. Have also tried API 32.

Your Environment

  • Plugin version: 0.1.4
  • Platform: Android
  • OS version: 11
  • Device manufacturer / model: L21 tablet
  • Cordova version (cordova -v): 10
  • Cordova platform version (cordova platform ls): 11.0.0
  • Plugin config
  • Ionic Version (if using Ionic)

Expected Behavior

Notification text should appear on the screen as it always has done.

Actual Behavior

No notification text appears.

Here's my triggering code, which has not changed.

                    channel: "channel1",
                    id: 100 + m,
                    text: String(reminders[n][0]),
                    priority: 2,
                    foreground: true,

                    trigger: {
                        every: {
                            weekday: Number(reminders[n][1][n1]) + 1, // days 1-7
                            hour: Number(reminders[n][2][0]),
                            minute: Number(reminders[n][2][1])
                        },
                        count: 1
                    }

Context

Debug logs

Many, many thanks!
Jon

@jondspa
Copy link
Author

jondspa commented Feb 3, 2023

Figured it out.

Similar to the suggestion on this thread: katzer/cordova-plugin-local-notifications#1589

I had to modify buildChannelWithOptions() to force importance=IMPORTANCE_HIGH in Manager.java.

public String buildChannelWithOptions(Uri soundUri, boolean shouldVibrate, boolean hasSound,
CharSequence channelName, String channelId) {
String defaultChannelId, newChannelId;
CharSequence defaultChannelName;
int importance;

    if (hasSound && shouldVibrate) {
        defaultChannelId = Options.SOUND_VIBRATE_CHANNEL_ID;
        defaultChannelName = Options.SOUND_VIBRATE_CHANNEL_NAME;
        importance = IMPORTANCE_HIGH;
        shouldVibrate = true;
    } else if (hasSound) {
        defaultChannelId = Options.SOUND_CHANNEL_ID;
        defaultChannelName = Options.SOUND_CHANNEL_NAME;
        importance = IMPORTANCE_DEFAULT;
        shouldVibrate = false;
    } else if (shouldVibrate) {
        defaultChannelId = Options.VIBRATE_CHANNEL_ID;
        defaultChannelName = Options.VIBRATE_CHANNEL_NAME;
        importance = IMPORTANCE_LOW;
        shouldVibrate = true;
    } else {
        defaultChannelId = Options.SILENT_CHANNEL_ID;
        defaultChannelName = Options.SILENT_CHANNEL_NAME;
        importance = IMPORTANCE_LOW;
        shouldVibrate = false;
    }

    newChannelId = channelId != null ? channelId : defaultChannelId;
    
    // newly added, force importance to be high
    importance = IMPORTANCE_HIGH;

    createChannel(newChannelId, channelName != null ? channelName : defaultChannelName, importance, shouldVibrate,
            soundUri);

    return newChannelId;
}

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

1 participant