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

(iOS) SyntaxError in plugin JS console messages #401

Closed
webcodepl opened this issue May 14, 2020 · 7 comments · Fixed by #430
Closed

(iOS) SyntaxError in plugin JS console messages #401

webcodepl opened this issue May 14, 2020 · 7 comments · Fixed by #430
Labels
bug Something isn't working properly ios relates to iOS platform runtime issue An issue related to app runtime

Comments

@webcodepl
Copy link

My configuration:

Model: iPhone X
Version: iOS 13.4.1

Model: MacBook Pro 13
Version: 10.15.4

Cordova 9.0.0 (cordova-lib@9.0.1)

cordova-custom-config 5.1.0 "cordova-custom-config"
cordova-plugin-androidx 1.0.2 "cordova-plugin-androidx"
cordova-plugin-androidx-adapter 1.1.1 "cordova-plugin-androidx-adapter"
cordova-plugin-customfcmreceiver 1.0.0 "Custom FCM Receiver"
cordova-plugin-dialogs 1.3.2-dev "Notification"
cordova-plugin-enable-multidex 0.2.0 "Enable Multidex"
cordova-plugin-firebasex 9.1.1 "Google Firebase Plugin"
cordova-plugin-whitelist 1.3.4 "Whitelist"

Xcode Version 11.4.1

Problem:

After receiving message i get error on console: SyntaxError: Unexpected EOF. I am sending message using:
npm run-script send -- --message=ios_data_notification.json --token="..."

ios fcm bug

I was trying also versions 8.0.1, 9.1.1-cli, compiling from xcode and xcodebuild, still the same error.

@dpa99c dpa99c transferred this issue from dpa99c/cordova-plugin-firebasex-test May 19, 2020
@dpa99c
Copy link
Owner

dpa99c commented May 19, 2020

I can repro this issue:
It's actually an issue with escaping of line endings for Javascript when sending log messages from the native iOS implementation to the Cordova Webview for display in the JS console.

For example, an expected log message would be:

console.log("FirebasePlugin[native]: didReceiveRemoteNotification: {\
    aps =     {\
        \"content-available\" = 1;\
    };\
    \"gcm.message_id\" = 1589924900140911;\
    \"key_1\" = \"Data for key one\";\
    messageType = data;\
    \"notification_body\" = \"Data message body\";\
    \"notification_foreground\" = true;\
    \"notification_ios_badge\" = 1;\
    \"notification_ios_sound\" = \"blackberry.caf\";\
    \"notification_title\" = \"Data message title\";\
}")

but the actual string being generated is:

console.log("FirebasePlugin[native]: didReceiveRemoteNotification: {
    aps =     {
        \"content-available\" = 1;
    };
    \"gcm.message_id\" = 1589924900140911;
    \"key_1\" = \"Data for key one\";
    messageType = data;
    \"notification_body\" = \"Data message body\";
    \"notification_foreground\" = true;
    \"notification_ios_badge\" = 1;
    \"notification_ios_sound\" = \"blackberry.caf\";
    \"notification_title\" = \"Data message title\";
}")

i.e. no escaping backslashses at the end of lines, resulting in the console error SyntaxError: Unexpected EOF.

@dpa99c dpa99c added bug Something isn't working properly ios relates to iOS platform runtime issue An issue related to app runtime labels May 19, 2020
@dpa99c dpa99c changed the title iOS - SyntaxError: Unexpected EOF (iOS) SyntaxError in plugin JS console messages May 19, 2020
@dpa99c dpa99c closed this as completed in 09af8d3 May 19, 2020
@dpa99c dpa99c added the ready for release Something has been implemented and is awaiting release to npm label May 19, 2020
duncan-c pushed a commit to howbout-ltd/cordova-plugin-firebasex that referenced this issue May 27, 2020
…sent from native iOS implementation to JS console. Resolves dpa99c#401.
@angjelkom
Copy link

@dpa99c it seems you accidentally reverted this change in: 116f5ce

could you plz merge it again?

@angjelkom
Copy link

@dpa99c I tried your fix but it doesn't seem to work fully I get: SyntaxError: Invalid escape in identifier: 'summary\' (my payload data contains object with key summary)

dpa99c added a commit that referenced this issue May 28, 2020
dpa99c pushed a commit that referenced this issue Jun 1, 2020
…sent from native iOS implementation to JS console. Resolves #401.
dpa99c added a commit that referenced this issue Jun 1, 2020
@dpa99c dpa99c removed the ready for release Something has been implemented and is awaiting release to npm label Jun 1, 2020
@angjelkom
Copy link

@dpa99c the fix doesn't work I am getting: SyntaxError: Invalid escape in identifier: 'summary\' my push data contains an object which has the key summary

@dpa99c
Copy link
Owner

dpa99c commented Jun 2, 2020

I will look at it again when I have some time

@dpa99c dpa99c reopened this Jun 2, 2020
@dpa99c
Copy link
Owner

dpa99c commented Jun 8, 2020

@EchoNox It looks like your keys are wrapped in single quotes:

SyntaxError: Invalid escape in identifier: 'summary'

which is invalid JSON.

Hence the Firebase Admin SDK will not allow a message to be sent containing single-quoted keys so I'm unable to reproduce your issue.

Can you confirm whether your keys are double-quoted or single-quoted?
In fact, if possible, can you supply a sample notification message which is causing you this issue.

@dpa99c
Copy link
Owner

dpa99c commented Jun 25, 2020

I believe this is resolved by #430

@dpa99c dpa99c closed this as completed Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working properly ios relates to iOS platform runtime issue An issue related to app runtime
Projects
None yet
3 participants