46
46
import static com .azure .reactnative .notificationhub .ReactNativeNotificationsHandler .RESOURCE_NAME_NOTIFICATION ;
47
47
48
48
public class NotificationHubUtil {
49
+ public static final String TAG = "NotificationHubUtil" ;
50
+
49
51
private static NotificationHubUtil sharedNotificationHubUtilInstance = null ;
50
52
51
53
private static final String SHARED_PREFS_NAME = "com.azure.reactnative.notificationhub.NotificationHubUtil" ;
@@ -316,13 +318,12 @@ public Intent createNotificationIntent(Context context, Bundle bundle, Class int
316
318
public void processNotificationActions (Context context , Bundle bundle ,
317
319
NotificationCompat .Builder notification ,
318
320
int notificationID ) {
319
- final String tag = ReactNativeNotificationsHandler .TAG ;
320
321
JSONArray actionsArray = null ;
321
322
try {
322
323
actionsArray = bundle .getString (KEY_REMOTE_NOTIFICATION_ACTIONS ) != null ?
323
324
new JSONArray (bundle .getString (KEY_REMOTE_NOTIFICATION_ACTIONS )) : null ;
324
325
} catch (JSONException e ) {
325
- Log .e (tag , ERROR_COVERT_ACTIONS , e );
326
+ Log .e (TAG , ERROR_COVERT_ACTIONS , e );
326
327
}
327
328
328
329
if (actionsArray != null ) {
@@ -335,7 +336,7 @@ public void processNotificationActions(Context context, Bundle bundle,
335
336
try {
336
337
action = actionsArray .getString (i );
337
338
} catch (JSONException e ) {
338
- Log .e (tag , ERROR_GET_ACTIONS_ARRAY , e );
339
+ Log .e (TAG , ERROR_GET_ACTIONS_ARRAY , e );
339
340
continue ;
340
341
}
341
342
@@ -351,6 +352,23 @@ public void processNotificationActions(Context context, Bundle bundle,
351
352
}
352
353
}
353
354
355
+ public NotificationCompat .Builder initNotificationCompatBuilder (Context context ,
356
+ String notificationChannelID ,
357
+ String title ,
358
+ CharSequence ticker ,
359
+ int visibility ,
360
+ int priority ,
361
+ boolean autoCancel ) {
362
+ NotificationCompat .Builder notificationBuilder = new NotificationCompat .Builder (context , notificationChannelID )
363
+ .setContentTitle (title )
364
+ .setTicker (ticker )
365
+ .setVisibility (visibility )
366
+ .setPriority (priority )
367
+ .setAutoCancel (autoCancel );
368
+
369
+ return notificationBuilder ;
370
+ }
371
+
354
372
private String getPref (Context context , String key ) {
355
373
SharedPreferences prefs =
356
374
context .getSharedPreferences (SHARED_PREFS_NAME , Context .MODE_PRIVATE );
0 commit comments