Skip to content
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

Android doesn't register device tokens #119

Open
khactam opened this issue May 15, 2018 · 6 comments
Open

Android doesn't register device tokens #119

khactam opened this issue May 15, 2018 · 6 comments

Comments

@khactam
Copy link

khactam commented May 15, 2018

Im using the version 1.0.8 and device registered a new Installation object fine but there is not device token has been saved in the object. The version 1.0.7 works fine but not the 1.0.8. What I want to use the version 1.0.8 is the silent notification (when I use 1.0.7, android gets the empty notification)

screen shot 2018-05-15 at 13 01 11

ionic: 3.20.0
cordova: 8.0.0

I use parse-server and it works fine until now.

My implement:

app.js

if(window.ParsePushPlugin){
      ParsePushPlugin.getInstallationId(function(id) {
          console.log("device installationId: " + id);
      }, function(e) {
          alert('error');
      });
}

config.xml

<preference name="ParseAppId" value="gijfdguo........." />
<preference name="ParseServerUrl" value="http://......../parse/" />
<preference name="ParseGcmSenderId" value="1........" />
@taivo
Copy link
Owner

taivo commented May 15, 2018

Hi @khactam , would you be able to help figure out what caused the loss of that functionality from the last version bump? And submit a PR. I don't currently have the setup to debug this quickly.

@khactam
Copy link
Author

khactam commented May 16, 2018

05-15 17:50:20.381 1169-13676/? I/ChromeSync: [Sync,SyncIntentOperation] Handling the intent: Intent { act=com.google.android.gms.chromesync.SCHEDULED_SYNC cat=[targeted_intent_op_prefix:.chromesync.sync.SyncIntentOperation] dat=content://com.google.android.gms.chromesync.sync.ChimeraSyncReceiverService/109125016589231836921 flg=0x4 cmp=com.google.android.gms/.chimera.GmsIntentOperationService launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } (has extras) }.
05-15 17:50:20.502 4333-4365/? E/Auth: [GoogleAccountDataServiceImpl] getToken() -> BAD_AUTHENTICATION. Account: <ELLIDED:1264340651>, App: com.google.android.gms, Service: oauth2:https://www.googleapis.com/auth/login_manager
    fzk: Long live credential not available.
        at fzl.b(:com.google.android.gms@12673021@12.6.73 (040306-194189626):20)
        at fzl.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):50)
        at fxv.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):38)
        at hox.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):8)
        at hox.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):189)
        at hnx.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):2)
        at hnu.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):17)
        at hnu.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):6)
        at cyb.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):25)
        at cyb.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):82)
        at cyb.onTransact(:com.google.android.gms@12673021@12.6.73 (040306-194189626):8)
        at android.os.Binder.transact(Binder.java:507)
        at dah.onTransact(:com.google.android.gms@12673021@12.6.73 (040306-194189626):3)
        at android.os.Binder.execTransact(Binder.java:573)
05-15 17:50:20.502 4333-4365/? W/Auth: [GetToken] GetToken failed with status code: BadAuthentication

And here from the terminal

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of null
    at module.exports (/Users/... 1/Documents/Tam/ionic-v1.3.1/../../plugins/parse-push-plugin/scripts/afterAndroidPrepare.js:15:99)
    at runScriptViaModuleLoader (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:188:18)
    at runScript (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:164:16)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:132:20
    at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/q/q.js:787:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/q/q.js:816:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:816:13)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:624:44
    at runSingle (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:137:13)
    at flush (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:125:13)
(node:32312) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:32312) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Not pretty sure if this could be useful

@khactam
Copy link
Author

khactam commented May 16, 2018

I found the problem. It's here in the afterAndroidPrepare.js.

 var parsePushNotificationIcon = configXml.data.find('preference[@name="ParseNotificationIcon"]').get('value');
  if (!!parsePushNotificationIcon) {
    // add to AndroidManifest.xml
    var manifestPushNotificationIconNode = applicationNode.find('meta-data[@android:name="com.parse.push.notification_icon"]');

    if (!manifestPushNotificationIconNode) {
      manifestPushNotificationIconNode = new ET.Element('meta-data', { 'android:name': 'com.parse.push.notification_icon' });
      applicationNode.append(manifestPushNotificationIconNode);
    }
    manifestPushNotificationIconNode.set('android:resource', '@drawable/' + parsePushNotificationIcon);

    // COPY ICON
    // create target path
    var iconTargetPath = path.join(context.opts.projectRoot, 'platforms', 'android', 'res', 'drawable');
    try {
      fs.mkdirSync(iconTargetPath);
    } catch (err) {
      // Directory already exists
    }

    // copy icon to android folder
    fs
      .createReadStream(path.join(context.opts.projectRoot, 'resources', parsePushNotificationIcon + '.png'))
      .pipe(fs.createWriteStream(path.join(iconTargetPath, parsePushNotificationIcon + '.png')));
  }

Just after I remove this (because I dont have the icon so it cant prepare perfectly. I put 1 condition there and everything is fine.

@taivo
Copy link
Owner

taivo commented May 19, 2018

@khactam thanks for figuring out the problem. Could you help by submitting a pull request?

@saisreeharsha
Copy link

saisreeharsha commented Feb 5, 2019

I found the problem. It's here in the afterAndroidPrepare.js.

 var parsePushNotificationIcon = configXml.data.find('preference[@name="ParseNotificationIcon"]').get('value');
  if (!!parsePushNotificationIcon) {
    // add to AndroidManifest.xml
    var manifestPushNotificationIconNode = applicationNode.find('meta-data[@android:name="com.parse.push.notification_icon"]');

    if (!manifestPushNotificationIconNode) {
      manifestPushNotificationIconNode = new ET.Element('meta-data', { 'android:name': 'com.parse.push.notification_icon' });
      applicationNode.append(manifestPushNotificationIconNode);
    }
    manifestPushNotificationIconNode.set('android:resource', '@drawable/' + parsePushNotificationIcon);

    // COPY ICON
    // create target path
    var iconTargetPath = path.join(context.opts.projectRoot, 'platforms', 'android', 'res', 'drawable');
    try {
      fs.mkdirSync(iconTargetPath);
    } catch (err) {
      // Directory already exists
    }

    // copy icon to android folder
    fs
      .createReadStream(path.join(context.opts.projectRoot, 'resources', parsePushNotificationIcon + '.png'))
      .pipe(fs.createWriteStream(path.join(iconTargetPath, parsePushNotificationIcon + '.png')));
  }

Just after I remove this (because I dont have the icon so it cant prepare perfectly. I put 1 condition there and everything is fine.

@khactam Where do i find this file named "afterAndroidPrepare.js" ???

@budda
Copy link

budda commented Nov 14, 2023

afterAndroidPrepare.js

@khactam Where do i find this file named "afterAndroidPrepare.js" ???

It's in the scripts folder

var parsePushNotificationIcon = configXml.data.find('preference[@name="ParseNotificationIcon"]').get('value');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants