...
CustomPushService
를 구현하세요.PushService
를 상속받는 클래스를 생성하세요.createYourNotificationChannel()
에서 Android 개발자 가이드의 알림 채널 만들기 및 관리 토픽을 참고하여 알림 채널을 만드세요. Android 8.0(API 레벨 26)부터는 모든 알림을 채널에 할당해야 합니다.getFeedPendingIntent()
에서 Feed로 진입할 수 있는PendingIntent
를 설정하세요.Code Block language java public class CustomPushService extends PushService { @NonNull @Override public Notification buildForegroundNotification(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { createYourNotificationChannel(); } return new NotificationCompat.Builder( context, YOUR_NOTIFICATION_CHANNEL_ID ) .setSmallIcon(context.applicationInfo.icon) .setContentIntent(getFeedPendingIntent(false)) // 아래 PushService 가 제공하는 API 참고 .setForegroundServiceBehavior(FOREGROUND_SERVICE_IMMEDIATE) .build(); } } private void createYourNotificationChannel() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationChannel channel = new NotificationChannel(YOUR_NOTIFICATION_CHANNEL_ID, YOUR_NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_LOW); NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.createNotificationChannel(channel); } }
Custom Service Class를 등록하세요.
Code Block language java // Push 초기화 참조 final PushConfig pushConfig = new PushConfig.Builder() .pushServiceClass(CustomPushService.class) ... .build(); final BuzzAdBenefitConfig buzzAdBenefitConfig = new BuzzAdBenefitConfig.Builder(context) ...생략... .setPushConfig(pushConfig) .build(); BuzzAdBenefit.init(this, buzzAdBenefitConfig);
AndroidManifest.xml 파일에
CustomPushService
를 등록하세요.Code Block language xml <application> ...생략... <service android:name=".custom.CustomPushService" /> </application>
...