-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Push Providers configuration #757
Closed
Closed
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
13a8b61
feat(SDK-4447) Deletes methods and fields for non firebase push provi…
CTLalit cfe1a52
feat(SDK-4447) Removes redundant platform handling
CTLalit faf7413
feat(SDK-4447) Removes annotations for string def
CTLalit 2fe4a6f
feat(SDK-4447) moves out pushtype enum
CTLalit 61938cb
feat(SDK-4448) converts enum to class
CTLalit 6d69bfe
feat(SDK-4449) fixes hms sdk compilation problems
CTLalit dcfe3a5
feat(SDK-4450) unwraps if else which is always true
CTLalit 42c9f59
feat(SDK-4450) fixes threading
CTLalit 30ffbdd
feat(SDK-4451) allows appending different providers via instance config
CTLalit 1d17a0c
feat(SDK-4451) fixes ctinstanceconfig via copy constructor
CTLalit a603d4c
chore(SDK-4451) moves constants related to config in correct place
CTLalit 33868c3
chore(SDK-4447) fixes typo
CTLalit e7a9a7b
feat(SDK-4452) passes pushtype in NotificationHandler
CTLalit 6d19ac5
chore(SDK-4447) removes huawei keyword
CTLalit 25a42f0
feat(SDK-4452) adds methods for utility
CTLalit 991347e
feat(SDK-4481) adds methods for utility
CTLalit 465b084
feat(SDK-4481) adds provider definition from manifest
CTLalit 69a6235
feat(SDK-4481) pr comments + test cases
CTLalit 8548a61
feat(SDK-4481) pr comments
CTLalit a3bb727
feat(SDK-4481) pr comments
CTLalit f463d7b
feat(SDK-4481) fixes correct strings
CTLalit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
import static com.clevertap.android.sdk.Utils.runOnUiThread; | ||
import static com.clevertap.android.sdk.pushnotification.PushConstants.FCM_LOG_TAG; | ||
import static com.clevertap.android.sdk.pushnotification.PushConstants.LOG_TAG; | ||
import static com.clevertap.android.sdk.pushnotification.PushConstants.PushType.FCM; | ||
import static com.clevertap.android.sdk.pushnotification.PushType.FCM; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.app.Activity; | ||
|
@@ -66,7 +66,7 @@ | |
import com.clevertap.android.sdk.pushnotification.CoreNotificationRenderer; | ||
import com.clevertap.android.sdk.pushnotification.INotificationRenderer; | ||
import com.clevertap.android.sdk.pushnotification.NotificationInfo; | ||
import com.clevertap.android.sdk.pushnotification.PushConstants.PushType; | ||
import com.clevertap.android.sdk.pushnotification.PushType; | ||
import com.clevertap.android.sdk.pushnotification.amp.CTPushAmpListener; | ||
import com.clevertap.android.sdk.task.CTExecutorFactory; | ||
import com.clevertap.android.sdk.task.Task; | ||
|
@@ -779,14 +779,18 @@ public static void setDebugLevel(LogLevel level) { | |
* @return The {@link CleverTapAPI} object | ||
*/ | ||
@SuppressWarnings("WeakerAccess") | ||
public static CleverTapAPI getDefaultInstance(Context context, String cleverTapID) { | ||
public static CleverTapAPI getDefaultInstance( | ||
Context context, | ||
String cleverTapID, | ||
List<PushType> pushTypes | ||
) { | ||
// For Google Play Store/Android Studio tracking | ||
sdkVersion = BuildConfig.SDK_VERSION_STRING; | ||
|
||
if (defaultConfig != null) { | ||
return instanceWithConfig(context, defaultConfig, cleverTapID); | ||
} else { | ||
defaultConfig = getDefaultConfig(context); | ||
defaultConfig = getDefaultConfig(context, pushTypes); | ||
if (defaultConfig != null) { | ||
return instanceWithConfig(context, defaultConfig, cleverTapID); | ||
} | ||
|
@@ -803,7 +807,20 @@ public static CleverTapAPI getDefaultInstance(Context context, String cleverTapI | |
@SuppressWarnings("WeakerAccess") | ||
public static @Nullable | ||
CleverTapAPI getDefaultInstance(Context context) { | ||
return getDefaultInstance(context, null); | ||
return getDefaultInstance(context, null, null); | ||
} | ||
|
||
/** | ||
* Returns the default shared instance of the CleverTap SDK, appends the given push types to | ||
* the providers for CleverTap push. | ||
* | ||
* @param context Application context | ||
* @return The {@link CleverTapAPI} object | ||
*/ | ||
@SuppressWarnings("WeakerAccess") | ||
public static @Nullable | ||
CleverTapAPI getDefaultInstance(Context context, List<PushType> pushTypes) { | ||
return getDefaultInstance(context, null, pushTypes); | ||
} | ||
|
||
private static CleverTapAPI fromAccountId(final Context context, final String _accountId) { | ||
|
@@ -981,13 +998,18 @@ public static void onActivityPaused() { | |
|
||
@SuppressWarnings("WeakerAccess") | ||
public static void onActivityResumed(Activity activity) { | ||
onActivityResumed(activity, null); | ||
onActivityResumed(activity, null, null); | ||
} | ||
|
||
@SuppressWarnings("WeakerAccess") | ||
public static void onActivityResumed(Activity activity, String cleverTapID) { | ||
public static void onActivityResumed(Activity activity, String cleverTapID, List<PushType> pushTypes) { | ||
if (instances == null) { | ||
CleverTapAPI.createInstanceIfAvailable(activity.getApplicationContext(), null, cleverTapID); | ||
CleverTapAPI.createInstanceIfAvailable( | ||
activity.getApplicationContext(), | ||
null, | ||
cleverTapID, | ||
pushTypes | ||
); | ||
} | ||
|
||
CoreMetaData.setAppForeground(true); | ||
|
@@ -2359,20 +2381,6 @@ public CTProductConfigController productConfig() { | |
return coreState.getCtProductConfigController(context); | ||
} | ||
|
||
/** | ||
* Sends the Baidu registration ID to CleverTap. | ||
* | ||
* @param regId The Baidu registration ID | ||
* @param register Boolean indicating whether to register | ||
* or not for receiving push messages from CleverTap. | ||
* Set this to true to receive push messages from CleverTap, | ||
* and false to not receive any messages from CleverTap. | ||
*/ | ||
@SuppressWarnings("unused") | ||
public void pushBaiduRegistrationId(String regId, boolean register) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are used by hybrids, can proably be refactored to |
||
coreState.getPushProviders().handleToken(regId, PushType.BPS, register); | ||
} | ||
|
||
/** | ||
* Push Charged event, which describes a purchase made. | ||
* | ||
|
@@ -2518,20 +2526,6 @@ public Future<?> pushGeofenceEnteredEvent(JSONObject geofenceProperties) { | |
.raiseEventForGeofences(Constants.GEOFENCE_ENTERED_EVENT_NAME, geofenceProperties); | ||
} | ||
|
||
/** | ||
* Sends the Huawei registration ID to CleverTap. | ||
* | ||
* @param regId The Huawei registration ID | ||
* @param register Boolean indicating whether to register | ||
* or not for receiving push messages from CleverTap. | ||
* Set this to true to receive push messages from CleverTap, | ||
* and false to not receive any messages from CleverTap. | ||
*/ | ||
@SuppressWarnings("unused") | ||
public void pushHuaweiRegistrationId(String regId, boolean register) { | ||
coreState.getPushProviders().handleToken(regId, PushType.HPS, register); | ||
} | ||
|
||
/** | ||
* Pushes the Notification Clicked event for App Inbox to CleverTap. | ||
* | ||
|
@@ -3091,29 +3085,15 @@ private void manifestAsyncValidation() { | |
}); | ||
} | ||
|
||
/** | ||
* Sends the ADM registration ID to CleverTap. | ||
* | ||
* @param token The ADM registration ID | ||
* @param register Boolean indicating whether to register | ||
* or not for receiving push messages from CleverTap. | ||
* Set this to true to receive push messages from CleverTap, | ||
* and false to not receive any messages from CleverTap. | ||
*/ | ||
@SuppressWarnings("unused") | ||
private void pushAmazonRegistrationId(String token, boolean register) { | ||
coreState.getPushProviders().handleToken(token, PushType.ADM, register); | ||
} | ||
|
||
static void onActivityCreated(Activity activity) { | ||
onActivityCreated(activity, null); | ||
onActivityCreated(activity, null, null); | ||
} | ||
|
||
// static lifecycle callbacks | ||
static void onActivityCreated(Activity activity, String cleverTapID) { | ||
static void onActivityCreated(Activity activity, String cleverTapID, List<PushType> pushTypes) { | ||
// make sure we have at least the default instance created here. | ||
if (instances == null) { | ||
CleverTapAPI.createInstanceIfAvailable(activity.getApplicationContext(), null, cleverTapID); | ||
CleverTapAPI.createInstanceIfAvailable(activity.getApplicationContext(), null, cleverTapID, pushTypes); | ||
} | ||
|
||
if (instances == null) { | ||
|
@@ -3178,15 +3158,20 @@ static void onActivityCreated(Activity activity, String cleverTapID) { | |
} | ||
|
||
private static CleverTapAPI createInstanceIfAvailable(Context context, String _accountId) { | ||
return createInstanceIfAvailable(context, _accountId, null); | ||
return createInstanceIfAvailable(context, _accountId, null, null); | ||
} | ||
|
||
private static @Nullable | ||
CleverTapAPI createInstanceIfAvailable(Context context, String _accountId, String cleverTapID) { | ||
CleverTapAPI createInstanceIfAvailable( | ||
Context context, | ||
String _accountId, | ||
String cleverTapID, | ||
List<PushType> pushTypes | ||
) { | ||
try { | ||
if (_accountId == null) { | ||
try { | ||
return CleverTapAPI.getDefaultInstance(context, cleverTapID); | ||
return CleverTapAPI.getDefaultInstance(context, cleverTapID, pushTypes); | ||
} catch (Throwable t) { | ||
Logger.v("Error creating shared Instance: ", t.getCause()); | ||
return null; | ||
|
@@ -3232,7 +3217,10 @@ public static ArrayList<CleverTapAPI> getAvailableInstances(Context context) { | |
* @param context The Android context | ||
* @return The {@link CleverTapInstanceConfig} object | ||
*/ | ||
private static CleverTapInstanceConfig getDefaultConfig(Context context) { | ||
private static CleverTapInstanceConfig getDefaultConfig( | ||
Context context, | ||
@Nullable List<PushType> pushTypes | ||
) { | ||
ManifestInfo manifest = ManifestInfo.getInstance(context); | ||
String accountId = manifest.getAccountId(); | ||
String accountToken = manifest.getAcountToken(); | ||
|
@@ -3248,9 +3236,16 @@ private static CleverTapInstanceConfig getDefaultConfig(Context context) { | |
Logger.i("Account Region not specified in the AndroidManifest - using default region"); | ||
} | ||
|
||
// todo lp pass manifest info here | ||
// todo : pass manifest info here | ||
CleverTapInstanceConfig defaultInstanceConfig = CleverTapInstanceConfig.createDefaultInstance(context, accountId, accountToken, accountRegion); | ||
|
||
if (pushTypes != null) { | ||
for (PushType pushType : pushTypes) { | ||
defaultInstanceConfig.addPushType(pushType); | ||
} | ||
} | ||
|
||
// todo : check if these re-assignments are needed, already added in manifest parsing | ||
if (proxyDomain != null && !proxyDomain.trim().isEmpty()) { | ||
defaultInstanceConfig.setProxyDomain(proxyDomain); | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be added to the documentation or consumer rules of HMS SDK