package com.oney.gcm;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

import com.facebook.react.LifecycleState;
import com.facebook.react.ReactInstanceManager;

import io.neson.react.notification.NotificationPackage;

public class BackgroundService extends Service {
    private static final String TAG = "BackgroundService";
    private ReactInstanceManager mReactInstanceManager;

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.d(TAG, "onStartCommand");

        mReactInstanceManager = ReactInstanceManager.builder()
                .setApplication(getApplication())
                .setBundleAssetName("index.android.bundle")
                .setJSMainModuleName("index.android")
                .addPackage(new MainReactPackage())
                .addPackage(new GcmPackage(intent))
                .setUseDeveloperSupport(false)
                .setInitialLifecycleState(LifecycleState.RESUMED)
                .build();
        mReactInstanceManager.createReactContextInBackground();

        return START_NOT_STICKY;
    }

    @Override
    public void onDestroy() {
        Log.d(TAG, "onDestroy");
        super.onDestroy();
        mReactInstanceManager.onPause();
        mReactInstanceManager.onDestroy();
        mReactInstanceManager = null;
    }
}

@@ -219,16 +219,49 @@
 nager;%0A%0A
+import java.lang.reflect.Field;%0A%0A
 import i
@@ -308,16 +308,16 @@
 ackage;%0A
-
 %0Apublic 
@@ -1058,13 +1058,29 @@
 ort(
-false
+getBuildConfigDEBUG()
 )%0A  
@@ -1454,32 +1454,32 @@
 er.onDestroy();%0A
-
         mReactIn
@@ -1505,11 +1505,913 @@
 l;%0A    %7D
+%0A%0A    private Class getBuildConfigClass() %7B%0A        try %7B%0A            String packageName = getPackageName();%0A%0A            return Class.forName(packageName + %22.BuildConfig%22);%0A        %7D catch (ClassNotFoundException e) %7B%0A            e.printStackTrace();%0A            return null;%0A        %7D%0A    %7D%0A    private boolean getBuildConfigDEBUG() %7B%0A        Class klass = getBuildConfigClass();%0A        for (Field f : klass.getDeclaredFields()) %7B%0A            Log.d(TAG, %22DeclaredField: %22 + f.getName());%0A            if (f.getName().equals(%22DEBUG%22)) %7B%0A                try %7B%0A                    Log.d(TAG, %22DeclaredField value: %22 + f.getBoolean(this));%0A                    return f.getBoolean(this);%0A                %7D catch (IllegalAccessException e) %7B%0A                    Log.d(TAG, %22DeclaredField fail%22);%0A                    e.printStackTrace();%0A                %7D%0A            %7D%0A        %7D%0A        return false;%0A    %7D
 %0A%7D%0A

use right BuildConfig.DEBUG