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

setPriority option missing #10

Closed
varunnayak opened this issue Jan 7, 2016 · 16 comments
Closed

setPriority option missing #10

varunnayak opened this issue Jan 7, 2016 · 16 comments

Comments

@varunnayak
Copy link

setPriority(Notification.PRIORITY_MAX) can be used to show Heads-up Notifications

@jkasten2
Copy link
Member

Thanks for the suggestion, we look into adding support for this in the future.

@olegdater
Copy link

this is much needed. When do you think you will implement this?
Need this for cordova plugin as well

@jkasten2
Copy link
Member

jkasten2 commented May 1, 2016

We are shooting to add this in the next few weeks.

@jkasten2
Copy link
Member

jkasten2 commented May 31, 2016

I created a NotificationExtenderService that can be used to set this or to customize any other setting before our SDK displays the notification. Follow our Background Data and Notification Overriding to set this up. Step 3 shows a code example getting access to NotificationCompat.Builder where you can call setPriority.

We still plan to build setPriority in based on GCM priority but since there is now a supported way to customize features I am going to make the this lower priority.

@raysango
Copy link

@jkasten2 I'm trying to setPriority(2) to make the notification displays as a banner, I followed Background Data and Notification Overriding like this

public class NotificationExtenderPriority extends NotificationExtenderService {
    @Override
    protected boolean onNotificationProcessing(OSNotificationReceivedResult receivedResult) {
        OverrideSettings overrideSettings = new OverrideSettings();
        overrideSettings.extender = new NotificationCompat.Extender() {
            @Override
            public NotificationCompat.Builder extend(NotificationCompat.Builder builder) {
                // Sets the background notification color to Green on Android 5.0+ devices.
                builder.setPriority(2);
                return builder;
            }
        };
        return true;
    }
}

And then updated AndroidManifest.xml (I placed it in the MainActivity):

  <service android:exported="false" android:name="com.ray.app.NotificationExtenderPriority">
                <intent-filter>
                    <action android:name="com.onesignal.NotificationExtender" />
                </intent-filter>
            </service>

but I think something is missing, is there any other way to make the notification appears as a banner because currently I just get the icon on the status bar.

@jkasten2
Copy link
Member

@raysango You need to add displayNotification(overrideSettings); before return true; to apply the overrideSettings.

@raysango
Copy link

@jkasten2 thanks, I added displayNotification(overrideSettings); but still the notification is displayed as icon in the status bar

@jkasten2
Copy link
Member

@raysango Can you confirm that builder.setPriority(2); is running by adding Log.e(...) after this and checking for it in the logcat?

Also note Heads Up notifications were introduced in Android 5.0 Lollipop, the setting is ignored on older Android devices.

@raysango
Copy link

@jkasten2 It's not being called, I can't see the log after adding OSNotificationDisplayedResult displayedResult = displayNotification(overrideSettings); Log.d("OneSignalExample", "Notification displayed with id: " + displayedResult.androidNotificationId);

The test device I'm using is Android 6.01 Marshmallow

@jkasten2
Copy link
Member

@raysango So it seems like your onNotificationProcessing method is being called but not the code in the extender? Note that this won't be called if you set an Android Group key from the dashboard or REST API for the notification. It is a current limitation of the SDK handling of grouped notifications.

@raysango
Copy link

@jkasten2 I'm using REST API to push notifications, but this is happening whether I assigned an android_group or not.

@jkasten2
Copy link
Member

@raysango Can you confirm the below from my previous response?

So it seems like your onNotificationProcessing method is being called but not the code in the extender?`

Lastly can you make sure your using our latest 3.3.0 SDK? You can print OneSignal.VERSION to conform the version is "030300".

@raysango
Copy link

@jkasten2 Thanks it is working now.

@jkasten2
Copy link
Member

@varunnayak @olegwn @raysango Priority is now set to PRIORITY_MAX when the send priority is set to 10 through our REST API call. This was added in our 3.4.0 release.

@floydus
Copy link

floydus commented Sep 21, 2017

Raysango, can you explain to me where to put the class NotificationExtenderPriority file I tried putting it where the MainActivity.java file is located under src/com/ionicframework but when I compile I get the following error.

NotificationExtenderBareBonesExample.java:5: error: method does not override or implement a method from a supertype
@OverRide
^
There is big lack of information on the onesignal documentation, it says to Create a class that extends NotificationExtenderService and implement the onNotificationProcessing method. But I have no clue on where to put that file..

Thanks sorry for being so confuse.

@jkasten2
Copy link
Member

@floydus Raysango's NotificationExtenderPriority class isn't needed any more since priority is built into the SDK now. You just need to set priority noted in my comment above. If you are sending your notification from the dashboard set Priority to high under options.

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

No branches or pull requests

5 participants