1

Ich werde verrückt bereits, ich mit phonegap-plugin-push, so zu arbeiten versucht:ionische-1 und Phonegap-plugin-Push I get "PushNotification ist nicht definiert"

   var options = { 
        android: { 
         senderID: "****" 
        }, 
        ios: { 
         alert: "true", 
         badge: "true", 
         sound: "true" 
        }, 
        windows: {} 
       }; 

       // initialize 
       $cordovaPushV5.initialize(options).then(function (data) { 
        alert(data); 
        console.log(data); 
        // start listening for new notifications 
        $cordovaPushV5.onNotification(); 
        // start listening for errors 
        $cordovaPushV5.onError(); 

        // register to get registrationId 
        $cordovaPushV5.register().then(function (registrationId) { 
         alert(registrationId); 
         console.log(registrationId); 
         $localStorage.token = registrationId; 
        }) 
       }); 

und ich Fehler:

Uncaught ReferenceError: PushNotification is not defined 
    at Object.initialize (ng-cordova.js:6378) 
    at app.js:69 

mit „Remote-Geräte“ ich sehe nicht einmal phonegap-plugin-push enter image description here

ich habe versucht, und zu ändern, wo rk mit cordova-plugin-firebase aber ich gat nicht Token, Ich habe versucht, mit window.FirebasePlugin.onTokenRefresh arbeiten und mit window.FirebasePlugin.getToken Ich habe wirklich alles versucht, aber nichts funktioniert für mich.

meine Plugins:

cordova-inappbrowser 1.0.6 "InAppBrowser" 
cordova-plugin-camera 2.4.1 "Camera" 
cordova-plugin-compat 1.1.0 "Compat" 
cordova-plugin-console 1.0.5 "Console" 
cordova-plugin-device 1.1.4 "Device" 
cordova-plugin-file 4.3.3 "File" 
cordova-plugin-file-transfer 1.6.3 "File Transfer" 
cordova-plugin-firebase 0.1.24 "Google Firebase Plugin" 
cordova-plugin-geolocation 2.4.3 "Geolocation" 
cordova-plugin-splashscreen 4.0.3 "Splashscreen" 
cordova-plugin-statusbar 2.2.1 "StatusBar" 
cordova-plugin-whitelist 1.3.2 "Whitelist" 
ionic-plugin-keyboard 2.2.1 "Keyboard" 
phonegap-plugin-push 2.0.0 "PushPlugin" 

ionische Info:

cli packages: (/usr/local/lib/node_modules) 

    @ionic/cli-utils : 1.9.2 
    ionic (Ionic CLI) : 3.9.2 

global packages: 

    Cordova CLI : 7.0.1 
    Gulp CLI : CLI version 3.9.1 Local version 3.9.1 

local packages: 

    Cordova Platforms : android 6.2.3 ios 4.4.0 
    Ionic Framework : ionic1 1.3.3 

System: 

    ios-sim : 6.0.0 
    Node : v6.10.2 
    npm  : 5.3.0 
    OS  : macOS Sierra 
    Xcode : Xcode 8.3.3 Build version 8E3004b 

Ich baue die App mit ionic package build android Wer für mich eine Lösung? Bitte!

+0

können Sie diesen Link versuchen https://stackoverflow.com/questions/38345799/pushnotification-is-undefined-ng-cordova –

+0

@sunielkalwani ich das versuchen, und Sie können auf dem Bild das Plugin nicht geladen sehen sogar, nebenbei funktioniert es mit phonegap build, aber ich arbeite mit ionic, weil ich auf phonegap nicht das symbol und den splash ersetzen konnte –

Antwort

1

Bitte testen Sie es in realen mobilen Gerät.Plugin wird nicht im Browser geladen.

Versuchen Sie, die initialize-Methode nach platform.ready-Ereignis aufzurufen.

angular.module('MainCtrl', ['ionic']) 
.controller('PushCtrl', function($scope,$cordovaPushV5) { 

    ionic.Platform.ready(function(){ 
    // will execute when device is ready, or immediately if the device is already ready. 
    console.log('Platform ready!'); 

    // initialize 
    $cordovaPushV5.initialize(options).then(function() { 
    // start listening for new notifications 
    $cordovaPushV5.onNotification(); 
    // start listening for errors 
    cordovaPushV5.onError(); 

    // register to get registrationId 
    $cordovaPushV5.register().then(function(registrationId) { 
     // save `registrationId` somewhere; 
     console.log(registrationId); 
    }) 
    }); 
    }); 

    if(ionic.Platform.device()){ 
     console.log("Push plugin loaded"); 
    }else{ 
    console.log("App is running in browser, push plugin will not load"); 
    }  
}); 
+0

danke, aber etwas komisches, baue ich die app mit 'ionic package build android' und ich lade die App von meinem Konto (in: https://apps.ionic.io/apps) und ich bekomme die "App läuft im Browser, Push-Plugin wird nicht geladen", mache ich etwas falsch? –

+0

Wie läuft die Anwendung? Ich meine, welchen Prozess du machst, um die Anwendung auszuführen ??? –

+0

Ich bin der Download apk und installieren ... –

Verwandte Themen