मैं इस ट्यूटोरियल का उपयोग करके फायरबेस का उपयोग करते समय हमेशा त्रुटि को संकलित करता हूं: https://firebase.google.com/docs/cloud-messaging/ios/client मेरा परिनियोजन एसडीके 9.0 है।फ़ायरबेस - 'UNUserNotificationCenterDelegate' टाइप करने के लिए 'AppDelegate' प्रकार का मान असाइन नहीं कर सकता है?
त्रुटियाँ मैं:
कैसे मैं इसे ठीक कर सकते हैं?
'UNUserNotificationCenterDelegate' टाइप करने के लिए 'AppDelegate' प्रकार के मान को असाइन नहीं किया जा सकता है?
1 परिदृश्य - मैं (ट्यूटोरियल के बाद) चरण दर चरण क्या किया: फली 'Firebase/कोर' फली 'Firebase/संदेश'
- फली init फली
- "आयात Firebase" स्थापित AppDelegate वर्ग
2 परिदृश्य की चोटी पर - डाउनलोड किए जाने एक GitHub भंडार के माध्यम से Ogle डेमो आईओएस ग्राहक एप्लिकेशन ("मेसेजिंग" https://github.com/firebase/quickstart-ios तहत फ़ोल्डर)
- उनके अनुप्रयोग संकलित ... ठीक काम किया।
- के लिए निम्न चरणों के अनुसार के रूप में उनके तर्क अपने मौजूदा XCode प्रोजेक्ट में compied: साथ निम्नलिखित
- फली init: फली 'Firebase/संदेश'
- फली
- आयातित निम्नलिखित स्थापित: UIKit, UserNotifications, Firebase , FirebaseInstanceID, FirebaseMessaging
AppDelegate में कोड:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// [START register_for_notifications]
if #available(iOS 10.0, *) {
let authOptions : UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: {_,_ in })
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.current().delegate = self
// For iOS 10 data message (sent via FCM)
FIRMessaging.messaging().remoteMessageDelegate = self
} else {
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()
// [END register_for_notifications]
FIRApp.configure()
// Add observer for InstanceID token refresh callback.
NotificationCenter.default.addObserver(self,
selector: #selector(self.tokenRefreshNotification),
name: .firInstanceIDTokenRefresh,
object: nil)
return true
}
अपने AppDelegate वर्ग को लागू करता है "UNUserNotificationCenterDelegate" प्रोटोकॉल किया: वह AppDelegate के अंत आप 2 एक्सटेंशन (UNUserNotificationCenterDelegate, FIRMessagingDelegate) जोड़ने के लिए
इस नमूने app से स्रोत कोड देखें की ज़रूरत है? यदि नहीं, तो कंपाइलर प्रकार से मेल नहीं खाता और यही कारण है कि त्रुटि देता है। – Surely
अजीब बात यह है कि Google के आईओएस क्लाइंट उदाहरण केवल यूआईआरएसस्पोन्डर, यूआईप्प्लिकेशन डिलीगेट लागू करता है ... मैंने यूएनयूसर नॉटिफिकेशन सेंटर डिलीगेट और एफआईआरमेसेजिंग डिलीगेट जोड़ा है। अब, यह कहता है "AppDelegate" "FIRMessagingDelegate" के साथ पुष्टि नहीं करता है। मैं इस पर शोध कर रहा हूँ। धन्यवाद। – user3427013
समझ गया ... उदाहरण में 2 एक्सटेंशन हैं ... lol लेकिन ट्यूटोरियल में इससे संबंधित कुछ भी नहीं है। वैसे भी। – user3427013