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

Registration function is not being invoked on iOS using Xcode (After upgrading to Version 2.3.0) #34

Closed
gvlot opened this issue Sep 15, 2020 · 12 comments

Comments

@gvlot
Copy link

gvlot commented Sep 15, 2020

Bug Report

After upgrading from version 2.1.3 to version 2.3.0 the registration function isn't invoked when deploying the app to IPHONE. The upgrade is necessary to overcome the malformed registrationId problem due to changes in iOS 13

Possible related bug reports:
phonegap#2940 (in my case the function is never being invoked no matter resets or clean build)
phonegap#2841

P.s. I am not sure if this problem only occurs when deploying from XCode. Unfortunately we can't deploy to appstore at this moment because it will eliminate the push notification functionality.

Expected Behaviour

registration function is being invoked

Actual Behaviour

registration is never being called.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Using Meteor platform version 1.10.0

Cordova plugins :
[email protected] [email protected] cordova-plugin-app-version@https://github.com/whiteoctober/cordova-plugin-app-version.git#bcfecaf9e4d20135a487de5502f7d1e3b251e062 [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]

Execute command :

meteor reset
meteor add-platform ios
meteor build --server $host

Open generated xcode project with XCode
Version : Version 11.7 (11E801a)

Deploy application on physical device : IPHONE Xr . IOS 13.7

The 'allow notifications' dialog isn't being displayed.

cordova info Printout

Cordova version 9 (provided by Meteor framework)

Sample Push Data Payload

'Hello'

Sample Code that illustrates the problem

if (Meteor.isCordova){
Meteor.startup(() => {

    this.push = PushNotification.init({
        android: {
            senderID: 123456
        },
    }, {
        ios: {
            alert : true,
            badge: true,
            sound: true,
        }
    });

    PushNotification.hasPermission(data => {
        if (data.isEnabled) {
            console.log('@@@@isEnabled');
        }
    });
    console.log('@@Initialized', this.push)
    this.push.on('error', function(e) {
        console.log('@@@@Error', e.message);
    });

    this.push.on('registration', (data) => {
        console.log('@@@#####Registration', JSON.stringify(data));
        let registrationId = data.registrationId;
        let majorVersion = 1;
        try{
            let version = device.version.split('.');
            majorVersion = parseInt(version[0]);
        }catch(e){
            majorVersion = 1;
        }

        //https://nshipster.com/apns-device-tokens/`
        if (device.platform === 'iOS' && majorVersion > 12){
            console.log('@@@S#####tarting IOS Registration', registrationId)
        }

        notification.registrationId = registrationId;
        console.log('@@@IOS Registration', registrationId);
        notification.name = device.model;
        notification.platform = device.platform;
        notification.version = device.version;
    });

    this.push.on('notification', function(data){
        console.log('@@notification', data);
        alert(data.message);
    });
});

}

Logs taken while reproducing problem

XCode logs :
-15 14:32:08.259569+0200 BizzStream[401:20023] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///private/var/mobile/Containers/Data/Application/670E60F3-5146-4F12-B93B-3629E56DBDF3/Library/Cookies/Cookies.binarycookies
2020-09-15 14:32:08.301249+0200 BizzStream[401:20023] Apache Cordova native platform version 5.1.1 is starting.
2020-09-15 14:32:08.301318+0200 BizzStream[401:20023] Multi-tasking -> Device: YES, App: YES
2020-09-15 14:32:08.315287+0200 BizzStream[401:20023]

Started backup to iCloud! Please be careful.
Your application might be rejected by Apple if you store too much data.
For more information please read "iOS Data Storage Guidelines" at:
https://developer.apple.com/icloud/documentation/data-storage/
To disable web storage backup to iCloud, set the BackupWebStorage preference to "local" in the Cordova config.xml file
2020-09-15 14:32:08.559203+0200 BizzStream[401:20023] WF: === Starting WebFilter logging for process BizzStream
2020-09-15 14:32:08.559252+0200 BizzStream[401:20023] WF: _userSettingsForUser mobile: {
filterBlacklist = (
);
filterWhitelist = (
);
restrictWeb = 1;
useContentFilter = 0;
useContentFilterOverrides = 0;
whitelistEnabled = 0;
}
2020-09-15 14:32:08.559292+0200 BizzStream[401:20023] WF: _WebFilterIsActive returning: NO
2020-09-15 14:32:08.576778+0200 BizzStream[401:20023] WF: _userSettingsForUser mobile: {
filterBlacklist = (
);
filterWhitelist = (
);
restrictWeb = 1;
useContentFilter = 0;
useContentFilterOverrides = 0;
whitelistEnabled = 0;
}
2020-09-15 14:32:08.576830+0200 BizzStream[401:20023] WF: _WebFilterIsActive returning: NO
2020-09-15 14:32:08.581479+0200 BizzStream[401:20023] WF: _userSettingsForUser mobile: {
filterBlacklist = (
);
filterWhitelist = (
);
restrictWeb = 1;
useContentFilter = 0;
useContentFilterOverrides = 0;
whitelistEnabled = 0;
}
2020-09-15 14:32:08.581514+0200 BizzStream[401:20023] WF: _WebFilterIsActive returning: NO
2020-09-15 14:32:09.207043+0200 BizzStream[401:20023] CDVWKWebViewEngine will reload WKWebView if required on resume
2020-09-15 14:32:09.207299+0200 BizzStream[401:20023] Using WKWebView
2020-09-15 14:32:09.207929+0200 BizzStream[401:20023] [CDVTimer][console] 0.129104ms
2020-09-15 14:32:09.208308+0200 BizzStream[401:20023] [CDVTimer][handleopenurl] 0.154972ms
2020-09-15 14:32:09.212153+0200 BizzStream[401:20023] Unlimited access to network resources
2020-09-15 14:32:09.212415+0200 BizzStream[401:20023] [CDVTimer][intentandnavigationfilter] 3.970981ms
2020-09-15 14:32:09.212668+0200 BizzStream[401:20023] [CDVTimer][gesturehandler] 0.138044ms
2020-09-15 14:32:09.237873+0200 BizzStream[401:20023] BLACKLIST - blacklistedVersions: []
2020-09-15 14:32:09.238157+0200 BizzStream[401:20023] BLACKLIST - versionsToRetry: []
2020-09-15 14:32:09.246485+0200 BizzStream[401:20023] Serving asset bundle version: 8daf51a3fe76633becc7a44492990aeef10a0a53
[INFO] GCDWebServer started on port 12904 and reachable at http://localhost:12904/
2020-09-15 14:32:09.248818+0200 BizzStream[401:20023] [CDVTimer][webapplocalserver] 36.024928ms
2020-09-15 14:32:09.250971+0200 BizzStream[401:20023] [CDVTimer][statusbar] 2.007008ms
2020-09-15 14:32:09.289123+0200 BizzStream[401:20023] [CDVTimer][splashscreen] 38.056016ms
2020-09-15 14:32:09.292265+0200 BizzStream[401:20023] [CDVTimer][file] 3.009915ms
2020-09-15 14:32:09.292475+0200 BizzStream[401:20023] [CDVTimer][inappbrowser] 0.133038ms
2020-09-15 14:32:09.294035+0200 BizzStream[401:20023] CDVPlugin class CDVUIInAppBrowser (pluginName: uiinappbrowser) does not exist.
2020-09-15 14:32:09.294116+0200 BizzStream[401:20023] [CDVTimer][uiinappbrowser] 1.567960ms
2020-09-15 14:32:09.294246+0200 BizzStream[401:20023] [CDVTimer][wkinappbrowser] 0.072956ms
2020-09-15 14:32:09.294314+0200 BizzStream[401:20023] [CDVTimer][TotalPluginStartup] 86.637020ms
2020-09-15 14:32:09.360854+0200 BizzStream[401:20023] [core] No URL for Apple ID Authorization
2020-09-15 14:32:09.364479+0200 BizzStream[401:20023] active
2020-09-15 14:32:09.365561+0200 BizzStream[401:20023] application first launch: remove badge icon number
2020-09-15 14:32:09.370195+0200 BizzStream[401:20023] PushPlugin skip clear badge
2020-09-15 14:32:09.370902+0200 BizzStream[401:20023] IAB.close() called but it was already closed.
2020-09-15 14:32:09.449588+0200 BizzStream[401:20023] [ProcessSuspension] 0x10d0e1d10 - ProcessAssertion::processAssertionWasInvalidated()
2020-09-15 14:32:09.495529+0200 BizzStream[401:20023] [ProcessSuspension] 0x10d0e1d70 - ProcessAssertion::processAssertionWasInvalidated()
2020-09-15 14:32:09.495755+0200 BizzStream[401:20023] [ProcessSuspension] 0x10d0e1dd0 - ProcessAssertion::processAssertionWasInvalidated()
2020-09-15 14:32:09.496317+0200 BizzStream[401:20023] [ProcessSuspension] 0x10d0e1e30 - ProcessAssertion::processAssertionWasInvalidated()
2020-09-15 14:32:10.403509+0200 BizzStream[401:20023] App startup confirmed
2020-09-15 14:32:10.404150+0200 BizzStream[401:20023] @@initialized [object Object]
2020-09-15 14:32:10.462881+0200 BizzStream[401:20023] Push Plugin VoIP missing or false
2020-09-15 14:32:10.463005+0200 BizzStream[401:20211] Push Plugin register called
2020-09-15 14:32:10.463028+0200 BizzStream[401:20211] PushPlugin.register: setting badge to false
2020-09-15 14:32:10.463045+0200 BizzStream[401:20211] PushPlugin.register: clear badge is set to 0
2020-09-15 14:32:10.463059+0200 BizzStream[401:20211] PushPlugin.register: better button setup
2020-09-15 14:32:10.463191+0200 BizzStream[401:20211] FCM Sender ID (null)
2020-09-15 14:32:10.463304+0200 BizzStream[401:20211] Using APNS Notification
2020-09-15 14:32:10.580705+0200 BizzStream[401:20023] Start downloading asset manifest from: manifest.json -- http://0c9a18ebcb17.eu.ngrok.io/__cordova/
2020-09-15 14:32:10.778459+0200 BizzStream[401:20214] Downloaded asset manifest for version: 595dc584044461cb34e7dd58f8af298f2e42cc1e
2020-09-15 14:32:10.778799+0200 BizzStream[401:20214] BLACKLIST - blacklistedVersions: []
2020-09-15 14:32:10.791899+0200 BizzStream[401:20211] Start downloading assets from bundle with version: 595dc584044461cb34e7dd58f8af298f2e42cc1e
2020-09-15 14:32:22.824511+0200 BizzStream[401:20214] [CDVTimer][assetBundleDownload] 12032.487988ms
2020-09-15 14:32:22.825638+0200 BizzStream[401:20212] Finished downloading new asset bundle version: 595dc584044461cb34e7dd58f8af298f2e42cc1e
2020-09-15 14:32:22.861725+0200 BizzStream[401:20023] Switching pending version 595dc584044461cb34e7dd58f8af298f2e42cc1e as the current asset bundle
2020-09-15 14:32:22.862266+0200 BizzStream[401:20023] Serving asset bundle version: 595dc584044461cb34e7dd58f8af298f2e42cc1e
2020-09-15 14:32:22.871331+0200 BizzStream[401:20023] [core] No URL for Apple ID Authorization
2020-09-15 14:32:22.872135+0200 BizzStream[401:20023] App startup timer started
2020-09-15 14:32:22.872280+0200 BizzStream[401:20023] IAB.close() called but it was already closed.
2020-09-15 14:32:24.247607+0200 BizzStream[401:20023] App startup confirmed
2020-09-15 14:32:24.248164+0200 BizzStream[401:20023] @@initialized [object Object]
2020-09-15 14:32:24.274422+0200 BizzStream[401:20023] Push Plugin VoIP missing or false
2020-09-15 14:32:24.274502+0200 BizzStream[401:20213] Push Plugin register called
2020-09-15 14:32:24.274537+0200 BizzStream[401:20213] PushPlugin.register: setting badge to false
2020-09-15 14:32:24.274557+0200 BizzStream[401:20213] PushPlugin.register: clear badge is set to 0
2020-09-15 14:32:24.274573+0200 BizzStream[401:20213] PushPlugin.register: better button setup
2020-09-15 14:32:24.274695+0200 BizzStream[401:20213] FCM Sender ID (null)
2020-09-15 14:32:24.274777+0200 BizzStream[401:20213] Using APNS Notification

@erisu
Copy link

erisu commented Sep 15, 2020

@gvlot Have you tried using this repo's master branch? A lot of updates had been pushed.

Also, I have not officially released this plugin yet to the npm registry. Once it is released, it will start over from version 1.0.0 since it will be a new npm package/plugin name. Right now, I been trying to review a lot of the existing PRs to see what I am able to merge in, at this time, before releasing.

You should be able to add this plugin with:

cordova plugin add github:havesource/cordova-plugin-push

@gvlot
Copy link
Author

gvlot commented Sep 15, 2020

Hello @erisu , that was fast !

First of all thanks for reaching out . Unfortunately I am not able to install the plugin for 'some' reason :

%% Failed to install 'havesource-cordova-plugin-push': Error: pod: Command failed with exit code 31
at ChildProcess.whenDone (/Users/gabryvlot/bizzstream/sa2/.meteor/local/cordova-build/node_modules/cordova-common/src/superspawn.js:135:23)
at ChildProcess.emit (events.js:311:20)
at maybeClose (internal/child_process.js:1021:16)
at Socket. (internal/child_process.js:443:11)
at Socket.emit (events.js:311:20)
at Pipe. (net.js:668:12)
=> Errors executing Cordova commands:

Because we are making use of the Meteor framework I used the following specification:
cordova-plugin-push@https://github.com/havesource/cordova-plugin-push.git#0962b763ac0c98a795860a8472b9a8b361f0807b

Hope you can help me further.

Thanks for your effort.

@gvlot
Copy link
Author

gvlot commented Sep 18, 2020

Hello @erisu ,

One small question regarding the invocation of the 'registration' function; How likely is it that this problem is related to the deployment of XCode? Will it work when the app will be deployed from the App Store?

Depending on your answer we can decided to publish an update of our app.

Thank your for your effort.

Kind regards,
G. Vlot

@albertleao
Copy link

albertleao commented Sep 22, 2020

cordova plugin add github:havesource/cordova-plugin-push

This command doesn't seem to work on cordova 8.1.2 (8.1.2 ([email protected]))

Failed to fetch plugin github:havesource/cordova-plugin-push via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Failed to get absolute path to installed module

Looks like the nofetch command is no longer in cordova

@andycnguyen
Copy link

Hello @erisu , that was fast !

First of all thanks for reaching out . Unfortunately I am not able to install the plugin for 'some' reason :

%% Failed to install 'havesource-cordova-plugin-push': Error: pod: Command failed with exit code 31
at ChildProcess.whenDone (/Users/gabryvlot/bizzstream/sa2/.meteor/local/cordova-build/node_modules/cordova-common/src/superspawn.js:135:23)
at ChildProcess.emit (events.js:311:20)
at maybeClose (internal/child_process.js:1021:16)
at Socket. (internal/child_process.js:443:11)
at Socket.emit (events.js:311:20)
at Pipe. (net.js:668:12)
=> Errors executing Cordova commands:

Because we are making use of the Meteor framework I used the following specification:
cordova-plugin-push@https://github.com/havesource/cordova-plugin-push.git#0962b763ac0c98a795860a8472b9a8b361f0807b

Hope you can help me further.

Thanks for your effort.

I'm currently getting a similar error. My initial impression is that cocoapods is unable to find plugin versions satisfying the podfile specification.

@kabachok169
Copy link

kabachok169 commented Oct 7, 2020

@erisu i have added ur plugin via github and still have this problem (registration is not triggered)
i have clean build with [email protected] and [email protected]
deploying it via XCode to ios 13.2 device

here is my code in index.ts

document.addEventListener("deviceready", () => {
  const push = window.PushNotification.init({
    android: {},
    browser: {
      pushServiceURL: 'http://push.api.phonegap.com/v1/push'
    },
    ios: {
      alert: 'true',
      badge: true,
      sound: 'false'
    },
    windows: {}
  })

  console.log('initing done')
  
  window.PushNotification.hasPermission((data: any) => {
    if (data.isEnabled) {
      console.log(data);
    }
  })
  
  push.on('registration', (data: any) => {
    console.log('registration event:', data)
  })
}, false);

i have initing done and isEnabled in my js logs but nothing more

i've tried with or without deviceready and once i`ve catched this event, but i don't know how
after few changes in my code(moving this part from index and back) and re-build app, i've lost it :(

i get the following logs (filtered by 'Push')

2020-10-07 16:34:06.404254-0700 eda-vendor[72016:890235] PushPlugin skip clear badge
2020-10-07 16:34:46.392650-0700 eda-vendor[72016:890235] Push Plugin VoIP missing or false
2020-10-07 16:34:46.392839-0700 eda-vendor[72016:890428] Push Plugin register called
2020-10-07 16:34:46.392953-0700 eda-vendor[72016:890428] PushPlugin.register: setting badge to false
r[72016:890428] PushPlugin.register: clear badge is set to 0
2020-10-07 16:34:46.393014-0700 eda-vendor[72016:890428] PushPlugin.register: better button setup

P.S. i've spent so many hours trying to understand what is wrong and will be really glad to your comment:)

@kabachok169
Copy link

UPD

I literally don't know what is the problem

I've woken up and then started debugging, i did nothing and then Push Plugin registered successfully
The behaviour of this thing is really unstable

Yesterday i realized that func didRegisterForRemoteNotificationsWithDeviceToken simply not being called, but now everything is fine

Trying to reproduce it anyway...

P.S. Sorry for my bag eng, my skills in it have deteriorated lately

@leventefabry
Copy link

Hello @erisu , that was fast !

First of all thanks for reaching out . Unfortunately I am not able to install the plugin for 'some' reason :

%% Failed to install 'havesource-cordova-plugin-push': Error: pod: Command failed with exit code 31
at ChildProcess.whenDone (/Users/gabryvlot/bizzstream/sa2/.meteor/local/cordova-build/node_modules/cordova-common/src/superspawn.js:135:23)
at ChildProcess.emit (events.js:311:20)
at maybeClose (internal/child_process.js:1021:16)
at Socket. (internal/child_process.js:443:11)
at Socket.emit (events.js:311:20)
at Pipe. (net.js:668:12)
=> Errors executing Cordova commands:

Because we are making use of the Meteor framework I used the following specification:
cordova-plugin-push@https://github.com/havesource/cordova-plugin-push.git#0962b763ac0c98a795860a8472b9a8b361f0807b

Hope you can help me further.

Thanks for your effort.

I have the same problem, can somebody have the idea, how to install the plugin?

@erisu
Copy link

erisu commented Oct 23, 2020

@gvlot

Sorry for the slow reply.

Reading through this issue ticket and what you last reported as the current error message is related to installing the pod spec.

This link below talks about the CocoaPods installation requirements. It also talks about this type of common issue, which you are having now.

https://github.com/havesource/cordova-plugin-push/blob/master/docs/INSTALLATION.md#cocoapods

If you are using the correct version, CocoaPods 1.8.0 or greater, and still having the issue, then make sure the pod repo is up-to-date or set up correctly. If needed, the repos can be set up again.

To check your current repo setup, run the command pod repo. You should see something like this:

trunk
- Type: CDN
- URL: https://cdn.cocoapods.org/
- Path: /Users/home/.cocoapods/repos/trunk

1 repo

This is what I actually have right now. I only have a trunk repo and it is a CDN type.

If what you have is identical to the above printout and having that issue, you can try to update the repo first with the command:

pod repo update trunk

If the trunk is missing, or the type is not CDN, you could recreate the repos with the following commands:

pod repo remove trunk
pod repo add-cdn trunk https://cdn.cocoapods.org/

This will remove and re-add the trunk as a CDN.

If you have more than 1 repo defined and do not need the other repos, you could also remove them. Other repos can be re-added by plugins depending on how they are configured etc.

After this, it should work. I had to recently do this myself.

@leventefabry, @andycnguyen: The same information applies to y'all as I see the same error message.

@erisu
Copy link

erisu commented Oct 23, 2020

@albertleao your issue is not the same as this ticket.

You are using an unsupported version of the Cordova CLI.

You should upgrade to the minimum supported version of 9.0.0. This version will be supported in the first major release of this plugin. An official release of 1.0.0 will be out soon.

I would even recommend upgrading to the current major release of Cordova CLI 10.0.0. This plugin will also have a second major release shortly after the first release and it is planned to only support cordova-cli >= 10.0.0.

If you are still having issues after upgrading and it is not the exact same issues as this ticket, please create a new ticket.

@erisu
Copy link

erisu commented Nov 19, 2024

This issue has been resolved in the main branch. A new version of the plugin will be released soon, and upgrading is recommended once it’s available.

If the issue persists after upgrading, please create a new ticket with updated information for further investigation.

@erisu erisu closed this as completed Nov 19, 2024
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants