Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

phonegap-plugin-push ionic 1 can't receive notification #2069

Closed
S3r3n4 opened this issue Nov 22, 2017 · 15 comments
Closed

phonegap-plugin-push ionic 1 can't receive notification #2069

S3r3n4 opened this issue Nov 22, 2017 · 15 comments

Comments

@S3r3n4
Copy link

S3r3n4 commented Nov 22, 2017

Reproduce Scenario (including but not limited to)

Hi everybody,
I'm new to use phonegap-plugin-push with ionic v1, I am finding this problem: when I send a notification my device does not receive it. The registration part works and I get the device tocken, but after that I don't receive notifications or errors when I send a notification by server. I'm sure the server sends a correct notification.

Platform and Version (Android 6.0 )

Cordova CLI version and cordova platform version

cordova --version                                    7.0.1
cordova platform version android                     6.2.3

Plugin version

cordova plugin version | grep phonegap-plugin-push   2.0.0

Sample Code that illustrates the problem

my code:
app.js

         `.run(function ($ionicPlatform, $window, $rootScope,ToastService,LocalStorageHelper) {
            $ionicPlatform.ready(function () {


    if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
        cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
        cordova.plugins.Keyboard.disableScroll(true);

    }
    if (window.StatusBar) {

        StatusBar.styleDefault();
    }

    const push = PushNotification.init({
        android: {
            senderID: "MY FIREBASE PROJECT ID", 
            sound: "true",
            vibrate: "true",
            icon: "phonegap",
            iconColor: "blue"
        },
        browser: {
            pushServiceURL: 'http://push.api.phonegap.com/v1/push'
        },
        ios: {
            alert: "true",
            badge: "true",
            sound: "true"
        },
        windows: {}
    });


    push.hasPermission((data) => {
        console.log('hasPermission data=')
        if (data.isEnabled) {
            console.log('isEnabled');
        }
    });


    push.on('registration', (data) => {
        // data.registrationId
        console.log('*****************')
        console.log('push success data=',data);
        console.log('*****************')
        LocalStorageHelper.setDeviceToken(data.registrationId)
    });

    push.on('notification', (data) => {
        // data.message,
        // data.title,
        // data.count,
        // data.sound,
        // data.image,
        // data.additionalData
        console.log('*****************')
        console.log('push notification data=',data);
        console.log('*****************')
    });

    push.on('error', (e) => {
        // e.message
        console.log('*****************')
        console.log('push Error data=',data);
        console.log('*****************')
    });


});}`

config.xml

    ` <plugin name="phonegap-plugin-push" spec="^2.0.0"/>           
       <platform name="android">
       <resource-file src="google-services.json" target="google-services.json" />
        </platform>
       <platform name="ios">
       <resource-file src="GoogleService-Info.plist" />
        </platform>`

pakage-json

 `"plugins": {
    "cordova-plugin-inappbrowser": {},
    "cordova-plugin-whitelist": {},
    "cordova-plugin-x-toast": {},
    "phonegap-plugin-barcodescanner": {
        "CAMERA_USAGE_DESCRIPTION": ""
    },
    "cordova-plugin-camera": {
        "CAMERA_USAGE_DESCRIPTION": " ",
        "PHOTOLIBRARY_USAGE_DESCRIPTION": " "
    },
    "cordova-plugin-file": {},
    "cordova-plugin-file-transfer": {},
    "cordova-plugin-email-composer": {},
    "phonegap-plugin-push": {}
}

Thanks in advance!

@macdonst
Copy link
Member

@S3r3n4 what does your payload look like? What do you see when running adb logcat | grep Push?

@S3r3n4
Copy link
Author

S3r3n4 commented Nov 22, 2017

hi, thanks for your reply!
After running adb logcat | grep Push I get:

11-22 17:33:09.873 8389 8407 D SPPClientService: PushLog.txt file is not deleted.
11-22 17:33:09.873 8389 8407 D SPPClientService: PushLog.txt file is not deleted.
11-22 17:33:09.873 8389 8407 D SPPClientService: ============PushLog. stop!
11-22 17:35:03.233 9610 9665 D Push_InsIdService: Refreshed token: elYnb3z9Jjo:APA91bFkXpsrAHeIfGsMeHmJcc0hS2pAdGUfg5IB6SMW7j6b0lE6Ev3DDG9B6oNCDrvoUUUrkMfbtw9GoAhE1msWeU9fTVzU6-o5Nt7rWLepaUGwsK3-6PP5MZ7v11433eRoi5Dnb9xk
11-22 17:35:05.403 9610 9734 V Push_Plugin: execute: action=hasPermission
11-22 17:35:05.473 9610 9734 V Push_Plugin: execute: action=init
11-22 17:35:05.473 9610 9735 V Push_Plugin: execute: data=[{"android":{"senderID":"pjoon.com:platform-storeden"},"browser":{"pushServiceURL":"http://push.api.phonegap.com/v1/push"},"ios":{"alert":"true","badge":"true","sound":"true"},"windows":{}}]
11-22 17:35:05.473 9610 9735 V Push_Plugin: execute: jo={"senderID":"pjoon.com:platform-storeden"}
11-22 17:35:05.473 9610 9735 V Push_Plugin: execute: senderID=1005267570499
11-22 17:35:05.473 9610 9735 V Push_Plugin: onRegistered: {"registrationId":"elYnb3z9Jjo:APA91bFkXpsrAHeIfGsMeHmJcc0hS2pAdGUfg5IB6SMW7j6b0lE6Ev3DDG9B6oNCDrvoUUUrkMfbtw9GoAhE1msWeU9fTVzU6-o5Nt7rWLepaUGwsK3-6PP5MZ7v11433eRoi5Dnb9xk","registrationType":"FCM"}
11-22 17:35:05.473 9610 9735 D Push_Plugin: no icon option
11-22 17:35:05.473 9610 9735 D Push_Plugin: no iconColor option

@macdonst
Copy link
Member

@S3r3n4 Yeah, so you are getting the registration ID fine. What logs, if any do you see when you send the push to the device? Also, I need to see your payload.

@S3r3n4
Copy link
Author

S3r3n4 commented Nov 22, 2017

I had try to catch the log when notification arrives on device but adb logcat |grep Push not write log.
I don't have the payload sent because i haven't access to the sender server

@macdonst
Copy link
Member

@S3r3n4 how are you sending the push.

@S3r3n4
Copy link
Author

S3r3n4 commented Nov 22, 2017

I use the website connected to old app, I send a message from website.
After that on the old app i get a notification.
I would see the notification on new app.

@macdonst
Copy link
Member

@S3r3n4 I'm not getting the necessary info I need in order to help you. Without more information they only think I can guess at is that your app is registering with a different project than the website is setting pushes to.

@S3r3n4
Copy link
Author

S3r3n4 commented Nov 27, 2017

Hi,
I had found the correct project, but now when I send the notification the app crashes without any error.
The adb logcat | greap push give me this when this app starts:

11-27 10:13:10.661 1108 1108 I GservicesProvider: Gservices pushing to system: true; secure/global: true
11-27 10:13:11.001 820 4785 I ActivityManager: Killing 28238:com.sec.spp.push/u0a58 (adj 15): DHA:empty #37
11-27 10:13:11.011 820 1745 D ActivityManager: isAutoRunBlockedApp:: com.sec.spp.push, Auto Run ON
11-27 10:24:12.671 4235 4362 V Push_Plugin: execute: data=[{"android":{"senderID":"289396574454"},"browser":{"pushServiceURL":"http://push.api.phonegap.com/v1/push"},"ios":{"alert":"true","badge":"true","sound":"true"},"windows":{}}]
11-27 10:24:12.681 4235 4235 D SystemWebChromeClient: file:///android_asset/www/js/app.js: Line 85 : push success data=
11-27 10:24:12.681 4235 4235 I chromium: [INFO:CONSOLE(85)] "push success data=", source: file:///android_asset/www/js/app.js (85)

What can I do to resolve the problem?

@S3r3n4
Copy link
Author

S3r3n4 commented Nov 27, 2017

I had tried with adb logcat only and about firebase it gave me:

11-27 11:14:17.111 25316 25316 D FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
11-27 11:14:17.121 314 1777 D libEGL : eglTerminate EGLDisplay = 0xb47af64c
11-27 11:14:17.121 314 314 D libEGL : eglTerminate EGLDisplay = 0xbecfa3c4
11-27 11:14:17.121 25316 25316 D FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
11-27 11:14:17.131 25316 25316 I FA : App measurement is starting up, version: 11011
11-27 11:14:17.131 25316 25316 I FA : To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
11-27 11:14:17.141 25316 25316 I FA : To enable faster debug mode event logging run:
11-27 11:14:17.141 25316 25316 I FA : adb shell setprop debug.firebase.analytics.app com.storeden.backoffice
11-27 11:14:17.141 820 998 D WindowAnimator: Skip setting animation background if there is an exiting window only.
11-27 11:14:17.141 25316 25316 W ResourcesManager: getTopLevelResources: /data/app/com.storeden.backoffice-1/base.apk / 1.0 running in com.storeden.backoffice rsrc of package null
11-27 11:14:17.151 25316 25316 I FirebaseInitProvider: FirebaseApp initialization successful
11-27 11:14:17.151 820 2624 V AlarmManager: remove PendingIntent] PendingIntent{ffada86: PendingIntentRecord{6080f47 com.storeden.backoffice broadcastIntent}}
11-27 11:14:17.151 820 998 D WindowAnimator: Skip setting animation background if there is an exiting window only.
11-27 11:14:17.161 25316 25316 W ResourcesManager: getTopLevelResources: /data/app/com.storeden.backoffice-1/base.apk / 1.0 running in com.storeden.backoffice rsrc of package null
11-27 11:14:17.161 25316 25316 W ResourcesManager: getTopLevelResources: /data/app/com.storeden.backoffice-1/base.apk / 1.0 running in com.storeden.backoffice rsrc of package null
11-27 11:14:17.171 820 998 D WindowAnimator: Skip setting animation background if there is an exiting window only.
11-27 11:14:17.171 820 1326 D NetworkPolicy: isUidForegroundLocked: 10037, mScreenOn: true, uidstate: 3, mProxSensorScreenOff: false
11-27 11:14:17.191 25316 25332 W ResourceType: No known package when getting value for resource number 0x0302005f
11-27 11:14:17.191 820 998 D WindowAnimator: Skip setting animation background if there is an exiting window only.
11-27 11:14:17.191 25316 25332 E Resources: RunTimeException
11-27 11:14:17.191 25316 25332 E Resources: android.content.res.Resources$NotFoundException: Resource ID #0x302005f
11-27 11:14:17.191 25316 25332 E Resources: at android.content.res.Resources.getValue(Resources.java:2558)
11-27 11:14:17.191 25316 25332 E Resources: at android.content.res.Resources.startRC(Resources.java:1116)
11-27 11:14:17.191 25316 25332 E Resources: at android.app.ActivityThread$mRunnable.run(ActivityThread.java:3055)
11-27 11:14:17.191 25316 25332 E Resources: at java.lang.Thread.run(Thread.java:818)

But the app registration is successful...

@S3r3n4
Copy link
Author

S3r3n4 commented Nov 27, 2017

To use phonegap-plugin-push I need install also cordova-plugin-fcm?

@macdonst
Copy link
Member

@S3r3n4 no, in fact that would be really bad as the two plugins would conflict with each other.

@S3r3n4
Copy link
Author

S3r3n4 commented Nov 28, 2017

Ok, thanks so much, what can I do to find the reason of crash of my app?

@S3r3n4
Copy link
Author

S3r3n4 commented Nov 29, 2017

Hi,
now the plugin works! :) I had change some configuration of cordova plugin facebook4, maybe the two plugins was conflict but I'm not sure of that.
Thanks so much for your help!!! :)

@lock
Copy link

lock bot commented Jun 3, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants