taivo / parse-push-plugin

Push notification plugin for Cordova/Phonegap/ionic on Parse platform
118 stars 102 forks source link

ParsePushPlugin.getInstallationId crashing on Android Device #111

Open toneloc83 opened 7 years ago

toneloc83 commented 7 years ago

Hi all,

Love the plugin, but having an issue with it running on an Android device. It works great on iOS and an Android Emulator, just not the device (keep getting the 'app stopped running' on load). Based on my research it looks like something isn't getting initialized when the device loads the app. It's more than likely an error on my part, but I feel like I've covered all the needed steps. I've also removed/added the plugin and android platform to try and get it to work.

I'll include some information below, but let me know what else I could provide to help!

config.xml

<widget id="com.pn.myapp" version="1.0.8" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <preference name="ParseAppId" value="parse_app_id" />
    <preference name="ParseClientKey" value="parse_client_key" />
    <preference name="ParseServerUrl" value="https://myserverurl.com/" />
    <preference name="ParseGcmSenderId" value="gcm_sender_id" />
    <preference name="ParseMultiNotifications" value="true" />
    <preference name="ParseAutoRegistration" value="true" />
    <preference name="ParseNotificationIcon" value="icon" />`
    <preference name="orientation" value="portrait" />
    <preference name="DisallowOverscroll" value="true" />
    <preference name="android-minSdkVersion" value="14" />
    <platform name="android">
        <allow-intent href="market:*" />
        <preference name="android-minSdkVersion" value="15" />
        <icon density="ldpi" src="www/res/icon/android/drawable-ldpi-icon.png" />
        <icon density="mdpi" src="www/res/icon/android/drawable-mdpi-icon.png" />
        <icon density="hdpi" src="www/res/icon/android/drawable-hdpi-icon.png" />
        <icon density="xhdpi" src="www/res/icon/android/drawable-xhdpi-icon.png" />
        <icon density="xxhdpi" src="www/res/icon/android/drawable-xxhdpi-icon.png" />
        <icon density="xxxhdpi" src="www/res/icon/android/drawable-xxxhdpi-icon.png" />
        <splash density="land-ldpi" src="www/res/screen/android/drawable-land-ldpi-screen.png" />
        <splash density="land-mdpi" src="www/res/screen/android/drawable-land-mdpi-screen.png" />
        <splash density="land-hdpi" src="www/res/screen/android/drawable-land-hdpi-screen.png" />
        <splash density="land-xhdpi" src="www/res/screen/android/drawable-land-xhdpi-screen.png" />
        <splash density="land-xxhdpi" src="www/res/screen/android/drawable-land-xxhdpi-screen.png" />
        <splash density="land-xxxhdpi" src="www/res/screen/android/drawable-land-xxxhdpi-screen.png" />
        <splash density="port-ldpi" src="www/res/screen/android/drawable-port-ldpi-screen.png" />
        <splash density="port-mdpi" src="www/res/screen/android/drawable-port-mdpi-screen.png" />
        <splash density="port-hdpi" src="www/res/screen/android/drawable-port-hdpi-screen.png" />
        <splash density="port-xhdpi" src="www/res/screen/android/drawable-port-xhdpi-screen.png" />
        <splash density="port-xxhdpi" src="www/res/screen/android/drawable-port-xxhdpi-screen.png" />
        <splash density="port-xxxhdpi" src="www/res/screen/android/drawable-port-xxxhdpi-screen.png" />
    </platform>
    <platform name="ios">
        <icon height="57" platform="ios" src="www/res/icon/ios/icon.png" width="57" />
        <icon height="114" platform="ios" src="www/res/icon/ios/icon@2x.png" width="114" />
        <icon height="40" platform="ios" src="www/res/icon/ios/icon-40.png" width="40" />
        <icon height="80" platform="ios" src="www/res/icon/ios/icon-40@2x.png" width="80" />
        <icon height="50" platform="ios" src="www/res/icon/ios/icon-50.png" width="50" />
        <icon height="100" platform="ios" src="www/res/icon/ios/icon-50@2x.png" width="100" />
        <icon height="60" platform="ios" src="www/res/icon/ios/icon-60.png" width="60" />
        <icon height="120" platform="ios" src="www/res/icon/ios/icon-60@2x.png" width="120" />
        <icon height="180" platform="ios" src="www/res/icon/ios/icon-60@3x.png" width="180" />
        <icon height="72" platform="ios" src="www/res/icon/ios/icon-72.png" width="72" />
        <icon height="144" platform="ios" src="www/res/icon/ios/icon-72@2x.png" width="144" />
        <icon height="76" platform="ios" src="www/res/icon/ios/icon-76.png" width="76" />
        <icon height="152" platform="ios" src="www/res/icon/ios/icon-76@2x.png" width="152" />
        <icon height="29" platform="ios" src="www/res/icon/ios/icon-small.png" width="29" />
        <icon height="58" platform="ios" src="www/res/icon/ios/icon-small@2x.png" width="58" />
        <icon height="87" platform="ios" src="www/res/icon/ios/icon-small@3x.png" width="87" />
        <splash height="1136" platform="ios" src="www/res/screen/ios/Default-568h@2x~iphone.png" width="640" />
        <splash height="1334" platform="ios" src="www/res/screen/ios/Default-667h.png" width="750" />
        <splash height="2208" platform="ios" src="www/res/screen/ios/Default-736h.png" width="1242" />
        <splash height="1242" platform="ios" src="www/res/screen/ios/Default-Landscape-736h.png" width="2208" />
        <splash height="1536" platform="ios" src="www/res/screen/ios/Default-Landscape@2x~ipad.png" width="2048" />
        <splash height="768" platform="ios" src="www/res/screen/ios/Default-Landscape~ipad.png" width="1024" />
        <splash height="2048" platform="ios" src="www/res/screen/ios/Default-Portrait@2x~ipad.png" width="1536" />
        <splash height="1024" platform="ios" src="www/res/screen/ios/Default-Portrait~ipad.png" width="768" />
        <splash height="960" platform="ios" src="www/res/screen/ios/Default@2x~iphone.png" width="640" />
        <splash height="480" platform="ios" src="www/res/screen/ios/Default~iphone.png" width="320" />
    </platform>
    <platform name="wp8">
        <icon height="99" platform="wp8" src="www/res/icon/wp8/ApplicationIcon.png" width="99" />
        <icon height="159" platform="wp8" src="www/res/icon/wp8/Background.png" width="159" />
        <splash height="1280" platform="wp8" src="www/res/screen/wp8/screen-portrait.jpg" width="768" />
    </platform>
    <platform name="windows">
        <icon height="150" platform="windows" src="www/res/icon/windows/Square150x150Logo.scale-100.png" width="150" />
        <icon height="30" platform="windows" src="www/res/icon/windows/Square30x30Logo.scale-100.png" width="30" />
        <icon height="50" platform="windows" src="www/res/icon/windows/StoreLogo.scale-100.png" width="50" />
        <splash height="300" platform="windows" src="www/res/screen/windows/SplashScreen.scale-100.png" width="620" />
        <icon height="120" platform="windows" src="www/res/icon/windows/StoreLogo.scale-240.png" width="120" />
        <icon height="44" platform="windows" src="www/res/icon/windows/Square44x44Logo.scale-100.png" width="44" />
        <icon height="106" platform="windows" src="www/res/icon/windows/Square44x44Logo.scale-240.png" width="106" />
        <icon height="70" platform="windows" src="www/res/icon/windows/Square70x70Logo.scale-100.png" width="70" />
        <icon height="71" platform="windows" src="www/res/icon/windows/Square71x71Logo.scale-100.png" width="71" />
        <icon height="170" platform="windows" src="www/res/icon/windows/Square71x71Logo.scale-240.png" width="170" />
        <icon height="360" platform="windows" src="www/res/icon/windows/Square150x150Logo.scale-240.png" width="360" />
        <icon height="310" platform="windows" src="www/res/icon/windows/Square310x310Logo.scale-100.png" width="310" />
        <icon height="150" platform="windows" src="www/res/icon/windows/Wide310x150Logo.scale-100.png" width="310" />
        <icon height="360" platform="windows" src="www/res/icon/windows/Wide310x150Logo.scale-240.png" width="744" />
        <splash height="1920" platform="windows" src="www/res/screen/windows/SplashScreenPhone.scale-240.png" width="1152" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <gap:config-file parent="NSPhotoLibraryUsageDescription" platform="ios">
        <string>For uploading receipt images</string>
    </gap:config-file>
    <preference name="AutoHideSplashScreen" value="false" />
    <preference name="SplashScreenDelay" value="2000" />
    <plugin name="com.telerik.plugins.nativepagetransitions" spec="^0.6.5" />
    <plugin name="cordova-plugin-battery-status" spec="~1.1.1" />
    <plugin name="cordova-plugin-camera" spec="~2.1.1" />
    <plugin name="cordova-plugin-console" spec="~1.0.2" />
    <plugin name="cordova-plugin-contacts" spec="~2.0.1" />
    <plugin name="cordova-plugin-device" spec="~1.1.1" />
    <plugin name="cordova-plugin-device-motion" spec="~1.2.0" />
    <plugin name="cordova-plugin-device-orientation" spec="~1.0.2" />
    <plugin name="cordova-plugin-dialogs" spec="~1.2.0" />
    <plugin name="cordova-plugin-file" spec="~4.1.1" />
    <plugin name="cordova-plugin-file-transfer" spec="~1.5.0" />
    <plugin name="cordova-plugin-geolocation" spec="~2.1.0" />
    <plugin name="cordova-plugin-globalization" spec="~1.0.3" />
    <plugin name="cordova-plugin-inappbrowser" spec="~1.3.0" />
    <plugin name="cordova-plugin-media" spec="~2.2.0" />
    <plugin name="cordova-plugin-media-capture" spec="~1.2.0" />
    <plugin name="cordova-plugin-network-information" spec="~1.2.0" />
    <plugin name="cordova-plugin-splashscreen" spec="~3.2.1" />
    <plugin name="cordova-plugin-statusbar" spec="~2.1.2" />
    <plugin name="cordova-plugin-uniquedeviceid" spec="^1.3.2" />
    <plugin name="cordova-plugin-vibration" spec="~2.1.0" />
    <plugin name="cordova-plugin-whitelist" spec="~1.2.1" />
    <plugin name="parse-push-plugin" spec="https://github.com/taivo/parse-push-plugin.git" />
</widget>

AndroidManifest.xml

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10008" android:versionName="1.0.8" package="com.pn.myapp" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />

    <application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:name="github.taivo.parsepushplugin.ParsePushApplication" android:supportsRtl="true">
        <meta-data android:name="com.parse.push.gcm_sender_id" android:value="id:361420033880" />;
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <service android:name="com.parse.PushService" />
        <receiver android:exported="false" android:name="github.taivo.parsepushplugin.ParsePushPluginReceiver">
            <intent-filter>
                <action android:name="com.parse.push.intent.RECEIVE" />
                <action android:name="com.parse.push.intent.DELETE" />
                <action android:name="com.parse.push.intent.OPEN" />
            </intent-filter>
        </receiver>
        <receiver android:name="com.parse.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="com.pn.myapp" />
            </intent-filter>
        </receiver>
        <service
            android:name=".MyFirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>
        <service
            android:name=".MyFirebaseInstanceIDService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
            </intent-filter>
        </service>
        <meta-data android:name="com.parse.push.notification_icon" android:resource="@mipmap/icon" />
    </application>
    <!-- <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="25" /> -->
    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <!-- ${packageName} is substituted for the package name declared above.  -->
    <permission android:protectionLevel="signature" android:name="com.pn.myapp.permission.C2D_MESSAGE" />
    <uses-permission android:name="com.pn.myapp.permission.C2D_MESSAGE" />
</manifest>

I ran some tests in Firebase and this is an exception shown:

FATAL EXCEPTION: pool-1-thread-2
Process: com.pn.myapp, PID: 8495
java.lang.NullPointerException
    at com.parse.ParseCorePlugins.getCurrentInstallationController(ParseCorePlugins.java:273)
    at com.parse.ParseInstallation.getCurrentInstallationController(ParseInstallation.java:53)
    at com.parse.ParseInstallation.getCurrentInstallation(ParseInstallation.java:59)
    at github.taivo.parsepushplugin.ParsePushPlugin$1.run(ParsePushPlugin.java:88)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    at java.lang.Thread.run(Thread.java:841)