0

私はpostmanとFirebaseで通知をプッシュしようとしていますが、iOS通知に問題があります。 私は無効なapns資格情報のエラーがあったので、Firebaseの設定が正しいと思いますが、今は成功しています。ionic 2 push on iosがデバイスに届かない

だから、これは私の郵便配達です:

enter image description here

そして、これは私が

initPushNotification() { 
if (!this.platform.is('cordova')) { 
    console.warn("Push notifications not initialized. Cordova is not available - Run in physical device"); 
    return; 
} 
const options: PushOptions = { 
    android: { 
    senderID: "883847118563" 
    }, 
    ios: { 
    senderID: "883847118563" 
    }, 
    windows: {} 
}; 
const pushObject: PushObject = this.push.init(options); 

pushObject.on('registration').subscribe((data: any) => { 
    console.log("device token ->", data.registrationId); 
    localStorage.setItem("pushToken", data.registrationId); 

    let alert = this.alertCtrl.create({ 
       title: 'device token', 
       subTitle: data.registrationId, 
       buttons: ['OK'] 
      }); 
      alert.present(); 

}); 

pushObject.on('notification').subscribe((data: any) => { 
    console.log('message', data.message); 
    if (data.additionalData.foreground) { 
    let confirmAlert = this.alertCtrl.create({ 
     title: 'New Notification', 
     message: data.message, 
     buttons: [{ 
     text: 'Ignore', 
     role: 'cancel' 
     }, { 
     text: 'View', 
     handler:() => { 
     // this.nav.push(DetailsPage, {message: data.message}); 
     } 
     }] 
    }); 
    confirmAlert.present(); 
    } else { 
    // this.nav.push(DetailsPage, {message: data.message}) 
    let alert = this.alertCtrl.create({ // o que fazer quando clica na app 
       title: 'clicked on', 
       subTitle: "you clicked on the notification!", 
       buttons: ['OK'] 
      }); 
      alert.present(); 
    console.log("Push notification clicked"); 
    } 
}); 

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

を使用しているコードであり、これは私の雲の設定です:

const cloudSettings: CloudSettings = { 
'core': { 
    'app_id': 'bde818c3' // ID da app @https://apps.ionic.io/apps/ 
    }, 
'push': { 
    'sender_id': '883847118563', 
    'pluginConfig': { 
    'ios': { 
    'badge': true, 
    'sound': true 
    }, 
    'android': { 
    'iconColor': '#ff0000' 
    } 
    } 
    } 
}; 

ここでのコードはテストのためのものであることに注意してください。 Androidは問題なく通知を受け取りますが、ipadは通知を受け取ることができません。私はios設定の通知を得るためにアプリにpermitionsを与えている... 何かアドバイスはありますか? ありがとうございました。

答えて

0

通知を受け取る方法を実装しましたか?

extension AppDelegate: UNUserNotificationCenterDelegate{ 


// Receive displayed notifications for iOS 10 devices. 
func userNotificationCenter(_ center: UNUserNotificationCenter, 
          willPresent notification: UNNotification, 
          withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { 
    let userInfo = notification.request.content.userInfo 

    // With swizzling disabled you must let Messaging know about the message, for Analytics 
    // Messaging.messaging().appDidReceiveMessage(userInfo) 



    // Print full message. 
    print(userInfo) 

    // Change this to your preferred presentation option 
    completionHandler([.alert,.sound]) 
} 


} 
関連する問題