@@ -287,27 +287,37 @@ public void scheduleNotification(Notification.Builder notificationBuilder) {
287
287
}
288
288
289
289
Notification scheduleAlarmWithNotification (Notification .Builder notificationBuilder , Intent intent , long fireTime ) {
290
+ return scheduleAlarmWithNotification (mContext , mOpenActivity , notificationBuilder , intent , fireTime );
291
+ }
292
+
293
+ static Notification scheduleAlarmWithNotification (Context context , Class activityClass , Notification .Builder notificationBuilder , Intent intent , long fireTime ) {
290
294
Bundle extras = notificationBuilder .getExtras ();
291
295
int id = extras .getInt (KEY_ID , -1 );
292
296
long repeatInterval = extras .getLong (KEY_REPEAT_INTERVAL , -1 );
293
297
// fireTime not taken from notification, because we may have adjusted it
294
298
295
- Notification notification = buildNotificationForSending (mContext , mOpenActivity , notificationBuilder );
299
+ Notification notification = buildNotificationForSending (context , activityClass , notificationBuilder );
296
300
mScheduledNotifications .put (Integer .valueOf (id ), notification );
297
301
intent .putExtra (KEY_NOTIFICATION_ID , id );
298
302
299
- PendingIntent broadcast = getBroadcastPendingIntent (mContext , id , intent , PendingIntent .FLAG_UPDATE_CURRENT );
300
- UnityNotificationManager .scheduleNotificationIntentAlarm (mContext , repeatInterval , fireTime , broadcast );
303
+ PendingIntent broadcast = getBroadcastPendingIntent (context , id , intent , PendingIntent .FLAG_UPDATE_CURRENT );
304
+ UnityNotificationManager .scheduleNotificationIntentAlarm (context , repeatInterval , fireTime , broadcast );
301
305
return notification ;
302
306
}
303
307
304
308
static void scheduleAlarmWithNotification (Notification .Builder notificationBuilder , Context context ) {
305
- if (mUnityNotificationManager == null )
306
- return ;
307
-
308
309
long fireTime = notificationBuilder .getExtras ().getLong (KEY_FIRE_TIME , 0L );
309
310
Intent intent = buildNotificationIntent (context );
310
- mUnityNotificationManager .scheduleAlarmWithNotification (notificationBuilder , intent , fireTime );
311
+
312
+ Class openActivity ;
313
+ if (mUnityNotificationManager == null || mUnityNotificationManager .mOpenActivity == null ) {
314
+ openActivity = UnityNotificationUtilities .getOpenAppActivity (context , true );
315
+ }
316
+ else {
317
+ openActivity = mUnityNotificationManager .mOpenActivity ;
318
+ }
319
+
320
+ scheduleAlarmWithNotification (context , openActivity , notificationBuilder , intent , fireTime );
311
321
}
312
322
313
323
protected static Notification buildNotificationForSending (Context context , Class openActivity , Notification .Builder builder ) {
@@ -637,13 +647,21 @@ public void onReceive(Context context, Intent intent) {
637
647
} else {
638
648
Notification .Builder builder = (Notification .Builder )notification ;
639
649
// this is different instance and does not have mOpenActivity
640
- if (builder == null || mUnityNotificationManager == null || mUnityNotificationManager . mOpenActivity == null ) {
650
+ if (builder == null ) {
641
651
Log .e (TAG_UNITY , "Failed to recover builder, can't send notification" );
642
652
return ;
643
653
}
644
654
655
+ Class openActivity ;
656
+ if (mUnityNotificationManager == null || mUnityNotificationManager .mOpenActivity == null ) {
657
+ openActivity = UnityNotificationUtilities .getOpenAppActivity (context , true );
658
+ }
659
+ else {
660
+ openActivity = mUnityNotificationManager .mOpenActivity ;
661
+ }
662
+
645
663
id = builder .getExtras ().getInt (KEY_NOTIFICATION_ID , -1 );
646
- notif = buildNotificationForSending (context , mUnityNotificationManager . mOpenActivity , builder );
664
+ notif = buildNotificationForSending (context , openActivity , builder );
647
665
// if notification is not sendable, it wasn't cached
648
666
mScheduledNotifications .put (Integer .valueOf (id ), notif );
649
667
}
0 commit comments