2017-11-08 12 views
1

현재 동작 : 푸시 플러그인을 사용했습니다. 푸시 동작에 대한 콜백 메소드를 정의하려고하면 다음 오류가 발생합니다.푸시 플러그인 액션 콜백 메서드를 이온으로 정의 할 수 없습니다.

[ts] ''accept ''유형의 인수를 'PushEvent'유형의 매개 변수에 지정할 수 없습니다.

[ts] '거부'유형의 인수를 'PushEvent'유형의 매개 변수에 지정할 수 없습니다.

관련 코드 :

this.push.hasPermission() 
     .then((res: any) => { 
      if (res.isEnabled) { 
     console.log('We have permission to send push notifications'); 
     } else { 
     console.log('We do not have permission to send push notifications'); 
     } 

    }); 
    const options: PushOptions = { 
     android: {}, 
     ios: { 
      alert: true, 
      badge: true, 
      sound: true, 
      "categories": { 
       "invite": { 
        "yes": { 
         "callback": "accept", "title": "Accept", "foreground": true, "destructive": false 
        }, 
        "no": { 
         "callback": "reject", "title": "Reject", "foreground": true, "destructive": false 
        }, 
        "maybe": { 
         "callback": "maybe", "title": "Maybe", "foreground": false, "destructive": false 
        } 
       }, 
       "delete": { 
        "yes": { 
         "callback": "doDelete", "title": "Delete", "foreground": false, "destructive": true 
        }, 
        "no": { 
         "callback": "cancel", "title": "Cancel", "foreground": false, "destructive": false 
        } 
       } 
      } 
     }, 
     windows: {}, 
     browser: { 
      pushServiceURL: 'http://push.api.phonegap.com/v1/push' 
     } 
    }; 


    const pushObject: PushObject = this.push.init(options); 


    pushObject.on('notification').subscribe((notification: any) => console.log('Received a notification', JSON.stringify(notification))); 

    pushObject.on('registration').subscribe((registration: any) => console.log('Device registered', JSON.stringify(registration))); 

    pushObject.on('error').subscribe(error => console.error('Error with Push plugin', error)); 

    pushObject.on('accept').subscribe(obj => console.log('accept a notification', JSON.stringify(obj))); 
    pushObject.on('reject').subscribe(obj => console.log('reject a notification', JSON.stringify(obj))); 

기타 정보 :

package.json 정보 : 그것은 분명 어떤 오류를 보여줍니다

{ 
    "name": "ionic-hello-world", 
    "author": "Ionic Framework", 
    "homepage": "http://ionicframework.com/", 
    "private": true, 
    "scripts": { 
     "clean": "ionic-app-scripts clean", 
     "build": "ionic-app-scripts build", 
     "ionic:build": "ionic-app-scripts build", 
     "ionic:serve": "ionic-app-scripts serve" 
    }, 
    "dependencies": { 
     "@angular/common": "2.4.8", 
     "@angular/compiler": "2.4.8", 
     "@angular/compiler-cli": "2.4.8", 
     "@angular/core": "2.4.8", 
     "@angular/forms": "2.4.8", 
     "@angular/http": "2.4.8", 
     "@angular/platform-browser": "2.4.8", 
     "@angular/platform-browser-dynamic": "2.4.8", 
     "@angular/platform-server": "2.4.8", 
     "@ionic-native/barcode-scanner": "^4.1.0", 
     "@ionic-native/battery-status": "^4.1.0", 
     "@ionic-native/broadcaster": "^4.1.0", 
     "@ionic-native/call-number": "^4.0.1", 
     "@ionic-native/camera": "^4.0.0", 
     "@ionic-native/core": "^3.6.1", 
     "@ionic-native/device-orientation": "^4.1.0", 
     "@ionic-native/email-composer": "^4.0.0", 
     "@ionic-native/file": "^4.0.1", 
     "@ionic-native/local-notifications": "^4.1.0", 
     "@ionic-native/network": "^4.0.0", 
     "@ionic-native/push": "^4.3.3", 
     "@ionic-native/qr-scanner": "^4.1.0", 
     "@ionic-native/screen-orientation": "^4.0.0", 
     "@ionic-native/screenshot": "^4.1.0", 
     "@ionic-native/sms": "^4.0.0", 
     "@ionic-native/social-sharing": "^4.0.0", 
     "@ionic-native/sqlite": "^4.0.1", 
     "@ionic/storage": "2.0.0", 
     "call-number": "0.0.2", 
     "com.darktalker.cordova.screenshot": "^0.1.6", 
     "cordova-android": "^6.3.0", 
     "cordova-ios": "^4.5.2", 
     "cordova-plugin-app-event": "file:node_modules/cordova-plugin-app-event", 
     "cordova-plugin-battery-status": "^1.2.4", 
     "cordova-plugin-broadcaster": "^2.3.0", 
     "cordova-plugin-camera": "^2.4.1", 
     "cordova-plugin-compat": "^1.2.0", 
     "cordova-plugin-console": "^1.1.0", 
     "cordova-plugin-device": "^1.1.6", 
     "cordova-plugin-device-orientation": "^1.0.7", 
     "cordova-plugin-email-composer": "^0.8.11", 
     "cordova-plugin-file": "^4.3.3", 
     "cordova-plugin-network-information": "^1.3.3", 
     "cordova-plugin-qrscanner": "^2.5.0", 
     "cordova-plugin-screen-orientation": "^2.0.1", 
     "cordova-plugin-splashscreen": "^4.0.3", 
     "cordova-plugin-statusbar": "^2.2.3", 
     "cordova-plugin-whitelist": "^1.3.2", 
     "cordova-plugin-x-socialsharing": "^5.2.1", 
     "cordova-sms-plugin": "^0.1.11", 
     "cordova-sqlite-storage": "^2.0.4", 
     "de.appplant.cordova.plugin.local-notification": "^0.8.5", 
     "es6-promise-plugin": "^4.1.0", 
     "ion-multi-picker": "^1.2.0", 
     "ionic-angular": "2.2.0", 
     "ionic-native": "2.4.1", 
     "ionic-plugin-keyboard": "^2.2.1", 
     "ionicons": "3.0.0", 
     "lodash": "^4.17.4", 
     "phonegap-plugin-barcodescanner": "^6.0.8", 
     "phonegap-plugin-push": "^1.10.5", 
     "pouchdb": "^6.3.4", 
     "pouchdb-find": "^6.3.4", 
     "relational-pouch": "^2.1.0", 
     "rxjs": "5.0.1", 
     "sw-toolbox": "3.4.0", 
     "zone.js": "0.7.2" 
    }, 
    "devDependencies": { 
     "@ionic/app-scripts": "^2.0.2", 
     "@ionic/cli-plugin-cordova": "1.6.1", 
     "@ionic/cli-plugin-ionic-angular": "1.4.1", 
     "ionic": "3.16.0", 
     "typescript": "2.0.9" 
    }, 
    "cordovaPlugins": [ 
     "cordova-plugin-whitelist", 
     "cordova-plugin-console", 
     "cordova-plugin-device", 
     "cordova-plugin-statusbar", 
     "ionic-plugin-keyboard", 
     "cordova-plugin-splashscreen" 
    ], 
    "cordovaPlatforms": [], 
    "description": "new: An Ionic project", 
    "cordova": { 
     "platforms": [ 
      "android", 
      "ios" 
     ], 
     "plugins": { 
      "cordova-plugin-console": {}, 
      "cordova-plugin-device": {}, 
      "cordova-plugin-splashscreen": {}, 
      "cordova-plugin-statusbar": {}, 
      "cordova-plugin-whitelist": {}, 
      "ionic-plugin-keyboard": {}, 
      "cordova-plugin-email-composer": {}, 
      "cordova-sms-plugin": {}, 
      "cordova-plugin-x-socialsharing": {}, 
      "cordova-plugin-screen-orientation": {}, 
      "cordova-plugin-network-information": {}, 
      "cordova-plugin-battery-status": {}, 
      "cordova-plugin-camera": { 
       "CAMERA_USAGE_DESCRIPTION": " ", 
       "PHOTOLIBRARY_USAGE_DESCRIPTION": " " 
      }, 
      "mx.ferreyra.callnumber": {}, 
      "call-number": {}, 
      "cordova-sqlite-storage": {}, 
      "cordova-plugin-file": {}, 
      "de.appplant.cordova.plugin.local-notification": {}, 
      "com.darktalker.cordova.screenshot": {}, 
      "cordova-plugin-broadcaster": {}, 
      "phonegap-plugin-push": { 
       "SENDER_ID": "85075801930" 
      } 
     } 
    } 
} 

답변

0

?

오류 :

Argument of type '"accept"' is not assignable to parameter of type 'PushEvent'.

Argument of type '"reject"' is not assignable to parameter of type 'PushEvent'.

솔루션 :

당신은 PushEvent .IT로 acceptreject를 사용할 수는 notification, registrationerror 만 있습니다.

여기에 the doc :

+0

감사합니다. sampath. 푸시 플러그인에서 그들은 [this] (https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#action-buttons-1)와 같이 말했습니다. 그런 다음 어떻게 calback 메소드를 정의 할 수 있습니까? – prabuganesan

+0

'iOS' 기기에서 이것을 테스트하고 있습니까? – Sampath

+0

예 예 테스트 작업을 테스트했습니다. 알림 수신 및 동작 버튼 표시. 그러나 나는 액션 콜백을 정의하려고 시도 할 수 없다. – prabuganesan