From e8179248f34c16205af996e8aaab282abe9e4bc2 Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Fri, 3 Jun 2016 16:52:41 +0300 Subject: [PATCH] Added PushWoosh --- android/AndroidManifest.xml | 50 +++++++++++++++++++ android/build.gradle | 8 +++ android/proguard-mwm.txt | 6 +++ .../com/mapswithme/maps/MwmApplication.java | 26 +++++++++- configure.sh | 4 ++ 5 files changed, 92 insertions(+), 2 deletions(-) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 845c6499ea..e4f5359f39 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -69,6 +69,18 @@ android:name="io.fabric.ApiKey" android:value="${FABRIC_API_KEY}"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/build.gradle b/android/build.gradle index 8984e14ca6..735d72f983 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -47,6 +47,7 @@ dependencies { // 3-party compile 'com.facebook.android:facebook-android-sdk:4.8.0' compile 'com.google.code.gson:gson:2.6.1' + compile 'com.pushwoosh:pushwoosh:4.1.3' compile fileTree(dir: '3rd_party', include: '*.jar') // BottomSheet compile project(":3rd_party:BottomSheet") @@ -92,6 +93,13 @@ android { props.load(new FileInputStream("${projectDir}/fabric.properties")); manifestPlaceholders = [ 'FABRIC_API_KEY': props['apiKey'] ] buildConfigField 'String', 'FABRIC_API_KEY', /"${props['apiKey']}"/ + + // PushWoosh keys + Properties pwProps = new Properties() + pwProps.load(new FileInputStream("${projectDir}/pushwoosh.properties")); + manifestPlaceholders += [ 'PW_APPID': pwProps['pwAppId'] ] + buildConfigField 'String', 'PW_APPID', /"${pwProps['pwAppId']}"/ + manifestPlaceholders += [ 'PW_PROJECT_ID': pwProps['pwProjectId'] ] } sourceSets.main { diff --git a/android/proguard-mwm.txt b/android/proguard-mwm.txt index 19697678b1..3d114434b2 100644 --- a/android/proguard-mwm.txt +++ b/android/proguard-mwm.txt @@ -12,6 +12,12 @@ -dontwarn okio.** -dontwarn com.facebook.** +# pushwoosh +-keep class com.pushwoosh.** { *; } +-keep class com.arellomobile.** { *; } +-dontwarn com.pushwoosh.** +-dontwarn com.arellomobile.** + # myTarget -dontwarn ru.mail.android.mytarget.** -dontwarn com.mopub.** diff --git a/android/src/com/mapswithme/maps/MwmApplication.java b/android/src/com/mapswithme/maps/MwmApplication.java index 1de77a3e52..61e6622b93 100644 --- a/android/src/com/mapswithme/maps/MwmApplication.java +++ b/android/src/com/mapswithme/maps/MwmApplication.java @@ -1,9 +1,7 @@ package com.mapswithme.maps; import android.app.Application; -import android.content.ComponentName; import android.content.SharedPreferences; -import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Environment; import android.os.Handler; @@ -32,6 +30,8 @@ import com.mapswithme.util.Constants; import com.mapswithme.util.ThemeSwitcher; import com.mapswithme.util.UiUtils; import com.mapswithme.util.statistics.Statistics; +import com.pushwoosh.PushManager; + import io.fabric.sdk.android.Fabric; import net.hockeyapp.android.CrashManager; @@ -39,6 +39,8 @@ public class MwmApplication extends Application { private final static String TAG = "MwmApplication"; + private static final String PW_EMPTY_APP_ID = "XXXXX"; + private static MwmApplication sSelf; private SharedPreferences mPrefs; private AppBackgroundTracker mBackgroundTracker; @@ -102,6 +104,7 @@ public class MwmApplication extends Application initHockeyApp(); initCrashlytics(); + initPushWoosh(); initPaths(); nativeInitPlatform(getApkPath(), getDataStoragePath(), getTempPath(), getObbGooglePath(), @@ -224,6 +227,25 @@ public class MwmApplication extends Application System.loadLibrary("mapswithme"); } + private void initPushWoosh() + { + try + { + if (BuildConfig.PW_APPID.equals(PW_EMPTY_APP_ID)) + return; + + PushManager pushManager = PushManager.getInstance(this); + + pushManager.onStartup(this); + pushManager.registerForPushNotifications(); + pushManager.startTrackingGeoPushes(); + } + catch(Exception e) + { + Log.e("Pushwoosh", e.getLocalizedMessage()); + } + } + public void initCounters() { if (!mAreCountersInitialized) diff --git a/configure.sh b/configure.sh index 2bada00f25..78da54d36f 100755 --- a/configure.sh +++ b/configure.sh @@ -8,6 +8,7 @@ BASE_PATH=`dirname "$0"` PRIVATE_HEADER="$BASE_PATH/private.h" PRIVATE_PROPERTIES="$BASE_PATH/android/secure.properties" PRIVATE_FABRIC_PROPERTIES="$BASE_PATH/android/fabric.properties" +PRIVATE_PUSHWOOSH_PROPERTIES="$BASE_PATH/android/pushwoosh.properties" SAVED_PRIVATE_REPO_FILE="$BASE_PATH/.private_repository_url" TMP_REPO_DIR="$BASE_PATH/.tmp.private.repo" @@ -59,6 +60,9 @@ else echo 'apiSecret=0000000000000000000000000000000000000000000000000000000000000000 apiKey=0000000000000000000000000000000000000000 ' > "$PRIVATE_FABRIC_PROPERTIES" + echo 'pwAppId=XXXXX +pwProjectId=A123456789012 +' > "$PRIVATE_PUSHWOOSH_PROPERTIES" exit fi fi