phonegap / phonegap-plugin-push

Register and receive push notifications
MIT License
1.94k stars 1.91k forks source link

not working on Android / iOS not tested yet #2166

Closed ghost closed 6 years ago

ghost commented 6 years ago

Expected Behaviour

to work

Actual Behaviour

not working

Reproduce Scenario (including but not limited to)

my index.html looks as follows:

> <!DOCTYPE html>
> <html>
>     <head>
>         <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
>         <meta name="format-detection" content="telephone=no">
>         <meta name="msapplication-tap-highlight" content="no">
>         <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
>         <link rel="stylesheet" type="text/css" href="css/index.css">
>         <title>013News App</title>
>         <script>
>       PushNotification.init({
>       android: {
>         senderID: XXXXXXXX (The actual number is in here)
>           }
>       });
>       </script>
>     </head>
>     <body>
>         <div class="app">
>             <h1>013News App</h1>
>             <div id="deviceready" class="blink">
>                 <p class="event listening">Connecting to Device</p>
>                 <p class="event received">Device is Ready</p>
>             </div>
>         </div>
>         <script type="text/javascript" src="cordova.js"></script>
>         <script type="text/javascript" src="js/index.js"></script>
>     </body>
> </html>

my config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.news.app" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
    <name>APPNAME</name>
    <description>
DESCRIPTION
    </description>
    <author email="email" href="website">
Author
    </author>
    <icon src="www/icon.png" />
    <splash src="www/splash.png" />
    <gap:config-file parent="CFBundleShortVersionString" platform="ios">
        <string>100</string>
    </gap:config-file>
    <content src="index.html" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <platform name="android">
        <preference name="loadUrlTimeoutValue" value="700000" />
    </platform>
    <plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
    <plugin name="cordova-plugin-splashscreen" spec="~5.0.1" />
    <plugin name="cordova-plugin-inappbrowser" spec="^2.0.1" />
    <plugin name="phonegap-plugin-push" spec="^2.1.2">
        <variable name="FCM_VERSION" value="11.0.1" />
        <variable name="SENDER_ID" value="XXXXXXX" />
    </plugin>
    <platform name="android">
    <resource-file src="google-services.json" target="app/google-services.json" />
</platform>
</widget>

Steps to Reproduce

I ran cordova plugin add phonegap-plugin-push followed by cordova plugin add phonegap-plugin-push --variable SENDER_ID="MYIDXXXXXX" and manually added

    <platform name="android">
    <resource-file src="google-services.json" target="app/google-services.json" />
</platform>

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

Testing it on several devices

Cordova CLI version and cordova platform version

cordova --version                                    8.0.0
cordova platform version android           7.0.0

Plugin version

phonegap-plugin-push 2.1.2 "PushPlugin"

macdonst commented 6 years ago

@mad2kx I'm closing this as filling out the issue template and only putting in "to work/not working" is not very helpful.

However, a couple of things I see is that you are using in inline script so make sure your content security policy allows in-line scripts. Also, you are trying to call PushNotification.init long before you get the deviceready event.

ghost commented 6 years ago

@macdonst I am batteling to have push notifications implemented into my app for a week now and I cannot seem to find a step-by-step tutorial which shows me where to add which code in the html files and js script

lock[bot] commented 6 years ago

This thread has been automatically locked.