-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1765 from OneSignal/user-model/notification-events
[User Model] Rename notification event listeners
- Loading branch information
Showing
57 changed files
with
615 additions
and
793 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
Examples/OneSignalDemo/app/src/main/java/com/onesignal/sdktest/constant/Tag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
package com.onesignal.sdktest.constant; | ||
|
||
public class Tag { | ||
|
||
public static final String DEBUG = "DEBUG"; | ||
public static final String ERROR = "ERROR"; | ||
|
||
public static final String LOG_TAG = "sdktest"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 9 additions & 14 deletions
23
...mo/app/src/main/java/com/onesignal/sdktest/notification/NotificationServiceExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,28 @@ | ||
package com.onesignal.sdktest.notification; | ||
|
||
import android.content.Context; | ||
import android.util.Log; | ||
|
||
import com.onesignal.notifications.IActionButton; | ||
import com.onesignal.notifications.IMutableNotification; | ||
import com.onesignal.notifications.INotification; | ||
import com.onesignal.notifications.IDisplayableMutableNotification; | ||
import com.onesignal.notifications.INotificationReceivedEvent; | ||
import com.onesignal.notifications.IRemoteNotificationReceivedHandler; | ||
import com.onesignal.notifications.INotificationServiceExtension; | ||
import com.onesignal.sdktest.R; | ||
import com.onesignal.sdktest.constant.Tag; | ||
|
||
public class NotificationServiceExtension implements IRemoteNotificationReceivedHandler { | ||
public class NotificationServiceExtension implements INotificationServiceExtension { | ||
|
||
@Override | ||
public void remoteNotificationReceived(Context context, INotificationReceivedEvent notificationReceivedEvent) { | ||
Log.v("MainApplication", "IRemoteNotificationReceivedHandler fired!" + " with INotificationReceivedEvent: " + notificationReceivedEvent.toString()); | ||
public void onNotificationReceived(INotificationReceivedEvent event) { | ||
Log.v(Tag.LOG_TAG, "IRemoteNotificationReceivedHandler fired" + " with INotificationReceivedEvent: " + event.toString()); | ||
|
||
INotification notification = notificationReceivedEvent.getNotification(); | ||
IDisplayableMutableNotification notification = event.getNotification(); | ||
|
||
if (notification.getActionButtons() != null) { | ||
for (IActionButton button : notification.getActionButtons()) { | ||
Log.v("MainApplication", "ActionButton: " + button.toString()); | ||
Log.v(Tag.LOG_TAG, "ActionButton: " + button.toString()); | ||
} | ||
} | ||
|
||
IMutableNotification mutableNotification = notification.mutableCopy(); | ||
mutableNotification.setExtender(builder -> builder.setColor(context.getResources().getColor(R.color.colorPrimary))); | ||
|
||
// If complete isn't call within a time period of 25 seconds, OneSignal internal logic will show the original notification | ||
notificationReceivedEvent.complete(mutableNotification); | ||
notification.setExtender(builder -> builder.setColor(event.getContext().getResources().getColor(R.color.colorPrimary))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.