|
38 | 38 | import com.leanplum.callbacks.StartCallback; |
39 | 39 | import com.leanplum.callbacks.VariablesChangedCallback; |
40 | 40 | import com.leanplum.internal.Constants; |
41 | | -import com.leanplum.internal.LeanplumEventDataManager; |
42 | 41 | import com.leanplum.internal.FileManager; |
43 | 42 | import com.leanplum.internal.JsonConverter; |
| 43 | +import com.leanplum.internal.LeanplumEventDataManager; |
44 | 44 | import com.leanplum.internal.LeanplumInternal; |
45 | 45 | import com.leanplum.internal.LeanplumMessageMatchFilter; |
46 | 46 | import com.leanplum.internal.LeanplumUIEditorWrapper; |
@@ -88,18 +88,15 @@ public class Leanplum { |
88 | 88 | new ArrayList<>(); |
89 | 89 | private static final ArrayList<VariablesChangedCallback> onceNoDownloadsHandlers = |
90 | 90 | new ArrayList<>(); |
| 91 | + private static final Object heartbeatLock = new Object(); |
91 | 92 | private static RegisterDeviceCallback registerDeviceHandler; |
92 | 93 | private static RegisterDeviceFinishedCallback registerDeviceFinishedHandler; |
93 | | - |
94 | 94 | private static LeanplumDeviceIdMode deviceIdMode = LeanplumDeviceIdMode.MD5_MAC_ADDRESS; |
95 | 95 | private static String customDeviceId; |
96 | 96 | private static boolean userSpecifiedDeviceId; |
97 | 97 | private static boolean initializedMessageTemplates = false; |
98 | 98 | private static boolean locationCollectionEnabled = true; |
99 | | - |
100 | 99 | private static ScheduledExecutorService heartbeatExecutor; |
101 | | - private static final Object heartbeatLock = new Object(); |
102 | | - |
103 | 100 | private static Context context; |
104 | 101 |
|
105 | 102 | private static Runnable pushStartCallback; |
@@ -765,6 +762,22 @@ protected Void doInBackground(Void... params) { |
765 | 762 | Log.d("No variants received from the server."); |
766 | 763 | } |
767 | 764 |
|
| 765 | + // Get notification channels and groups. |
| 766 | + JSONArray notificationChannels = response.optJSONArray( |
| 767 | + Constants.Keys.NOTIFICATION_CHANNELS); |
| 768 | + JSONArray notificationGroups = response.optJSONArray( |
| 769 | + Constants.Keys.NOTIFICATION_GROUPS); |
| 770 | + String defaultNotificationChannel = response.optString( |
| 771 | + Constants.Keys.DEFAULT_NOTIFICATION_CHANNEL); |
| 772 | + |
| 773 | + // Configure notification channels and groups |
| 774 | + LeanplumNotificationChannel.configureNotificationGroups( |
| 775 | + context, notificationGroups); |
| 776 | + LeanplumNotificationChannel.configureNotificationChannels( |
| 777 | + context, notificationChannels); |
| 778 | + LeanplumNotificationChannel.configureDefaultNotificationChannel( |
| 779 | + context, defaultNotificationChannel); |
| 780 | + |
768 | 781 | String token = response.optString(Constants.Keys.TOKEN, null); |
769 | 782 | Request.setToken(token); |
770 | 783 | Request.saveToken(); |
@@ -883,7 +896,6 @@ public void run() { |
883 | 896 | LeanplumInternal.onHasStartedAndRegisteredAsDeveloper(); |
884 | 897 | } |
885 | 898 | } |
886 | | - |
887 | 899 | LeanplumInternal.moveToForeground(); |
888 | 900 | startHeartbeat(); |
889 | 901 | } catch (Throwable t) { |
@@ -1928,13 +1940,13 @@ public void response(JSONObject response) { |
1928 | 1940 | } |
1929 | 1941 | }); |
1930 | 1942 | req.onError(new Request.ErrorCallback() { |
1931 | | - @Override |
1932 | | - public void error(Exception e) { |
1933 | | - if (callback != null) { |
1934 | | - OsHandler.getInstance().post(callback); |
1935 | | - } |
1936 | | - } |
1937 | | - }); |
| 1943 | + @Override |
| 1944 | + public void error(Exception e) { |
| 1945 | + if (callback != null) { |
| 1946 | + OsHandler.getInstance().post(callback); |
| 1947 | + } |
| 1948 | + } |
| 1949 | + }); |
1938 | 1950 | req.sendIfConnected(); |
1939 | 1951 | } catch (Throwable t) { |
1940 | 1952 | Util.handleException(t); |
|
0 commit comments