Skip to content

Commit

Permalink
Fixing merge issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
billmote committed Jun 14, 2022
1 parent 82fbd52 commit 05e951d
Showing 1 changed file with 70 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.content.Intent;
import android.net.Uri;
import android.util.Log;

import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
Expand All @@ -16,67 +17,86 @@
import com.salesforce.marketingcloud.MCLogListener;
import com.salesforce.marketingcloud.UrlHandler;
import com.salesforce.marketingcloud.notifications.NotificationCustomizationOptions;
import com.salesforce.marketingcloud.registration.Registration;
import com.salesforce.marketingcloud.registration.RegistrationManager;

import java.util.*;

import org.json.JSONException;

public class MainApplication extends Application implements ReactApplication, UrlHandler {

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
private static final String TAG = "~#MainApplication";

@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}

@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable") List<ReactPackage> packages =
new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}

@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
@Override protected String getJSMainModuleName() {
return "index";
}
};

@Override public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}

@Override public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);

@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
// For DEBUG Builds -- Never release with logging enabled.
if (BuildConfig.DEBUG) {
// Turn on VERBOSE Logging
MarketingCloudSdk.setLogLevel(MCLogListener.VERBOSE);
MarketingCloudSdk.setLogListener(new MCLogListener.AndroidLogListener());

if (BuildConfig.DEBUG) {
MarketingCloudSdk.setLogLevel(MCLogListener.VERBOSE);
MarketingCloudSdk.setLogListener(new MCLogListener.AndroidLogListener());
// Get the SDK when it's ready
MarketingCloudSdk.requestSdk(new MarketingCloudSdk.WhenReadyListener() {
@Override public void ready(MarketingCloudSdk sdk) {
try {
// Log the SDK's state when the application is initialized
Log.i(TAG, "State: " + sdk.getSdkState().toString(2));
} catch (JSONException e) {
// NO-OP
}

// Register a Registration Listener
sdk.getRegistrationManager()
.registerForRegistrationEvents(new RegistrationManager.RegistrationEventListener() {
@Override public void onRegistrationReceived(Registration registration) {

// Output Registration Changes to the Logcat
Log.i(TAG, "Registration: " + registration);
}
});
}

MarketingCloudSdk.init(this,
MarketingCloudConfig.builder()
.setApplicationId(this.getResources().getString(R.string.PUSH_APPLICATION_ID))
.setAccessToken(this.getResources().getString(R.string.PUSH_ACCESS_TOKEN))
.setSenderId(this.getResources().getString(R.string.PUSH_SENDER_ID))
.setMarketingCloudServerUrl(this.getResources().getString(R.string.PUSH_TSE))
.setNotificationCustomizationOptions(NotificationCustomizationOptions.create(R.drawable.ic_notification))
.setAnalyticsEnabled(true)
.setUrlHandler(this)
.build(this),
initializationStatus -> Log.i("~#MainApplication", initializationStatus.toString()));
});
}

@Override
public PendingIntent handleUrl(Context context, String url, String urlSource) {
return PendingIntent.getActivity(
context,
new Random().nextInt(),
new Intent(Intent.ACTION_VIEW, Uri.parse(url)),
PendingIntent.FLAG_UPDATE_CURRENT
);
}

MarketingCloudSdk.init(this, MarketingCloudConfig.builder()
.setApplicationId(this.getResources().getString(R.string.PUSH_APPLICATION_ID))
.setAccessToken(this.getResources().getString(R.string.PUSH_ACCESS_TOKEN))
.setSenderId(this.getResources().getString(R.string.PUSH_SENDER_ID))
.setMarketingCloudServerUrl(this.getResources().getString(R.string.PUSH_TSE))
.setNotificationCustomizationOptions(
NotificationCustomizationOptions.create(R.drawable.ic_notification))
.setAnalyticsEnabled(true)
.setUrlHandler(this)
.build(this), initializationStatus -> Log.i(TAG, "InitStatus: " + initializationStatus.toString()));
}

@Override public PendingIntent handleUrl(Context context, String url, String urlSource) {
return PendingIntent.getActivity(context, new Random().nextInt(),
new Intent(Intent.ACTION_VIEW, Uri.parse(url)), PendingIntent.FLAG_UPDATE_CURRENT);
}
}

0 comments on commit 05e951d

Please sign in to comment.