Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. CustomPushService를 구현하세요.

    • PushService를 상속받는 클래스를 생성하세요.

    • createYourNotificationChannel() 에서 Android 개발자 가이드의 알림 채널 만들기 및 관리 토픽을 참고하여 알림 채널을 만드세요. Android 8.0(API 레벨 26)부터는 모든 알림을 채널에 할당해야 합니다.

    • getFeedPendingIntent()에서 Feed로 진입할 수 있는 PendingIntent를 설정하세요.

      Code Block
      languagejava
      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);
          }
      }

  2. Custom Service Class를 등록하세요.

    Code Block
    languagejava
    // 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);

  3. AndroidManifest.xml 파일에 CustomPushService를 등록하세요.

    Code Block
    languagexml
    <application>
        ...생략...
        <service android:name=".custom.CustomPushService" /> 
    </application>
    

...