Giter Site home page Giter Site logo

Comments (10)

derBeukatt avatar derBeukatt commented on June 22, 2024

Hey there.

Is this just a specific problem for me or does anyone else run into this.

from awesome_notifications.

rafaelsetragni avatar rafaelsetragni commented on June 22, 2024

I was unable to reproduce your error. What steps did you take to create your iOS app?

Try modifying the messaging method below in your local code:

public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {

from awesome_notifications.

derBeukatt avatar derBeukatt commented on June 22, 2024

Hi. Thanks for your answer.

I was just normally building my app via "flutter clean" followed by "flutter build ios" and the error occured.
I already did modify the following code:

https://github.com/rafaelsetragni/awesome_notifications/blob/b3e4da96f0302fef43f4c801d819dad044021332/ios/Classes/lib/SwiftAwesomeNotificationsPlugin.swift#L104

public func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
        print("Firebase registration token: \(fcmToken)")

        let dataDict:[String: String] = ["token": fcmToken]
        NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict)
        // TODO: If necessary send token to application server.
        // Note: This callback is fired at each app startup and whenever a new token is generated.
}

to the following

public func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
        if let unwrapped = fcmToken {
            print("Firebase registration token: \(unwrapped)")
            let dataDict:[String: String] = ["token": unwrapped]
            NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict)
            // TODO: If necessary send token to application server.
            // Note: This callback is fired at each app startup and whenever a new token is generated.
        }
}

But I just don't know why I had to do this.

from awesome_notifications.

rafaelsetragni avatar rafaelsetragni commented on June 22, 2024

You are rigth. My messaging method is deprecated, thats why you couldnt compile the final version in your app. I gonna update it.
Did you use another firebase services in your app? What version are they?

Edited:

I put your mod into my project and XCode complained back:

Parameter of 'messaging(_:didReceiveRegistrationToken:)' has different optionality than expected by protocol 'MessagingDelegate'
Remove '?'

image

Better! Do you wanna do a fork and send me this fix? Your name will be included as this project contributor.

from awesome_notifications.

derBeukatt avatar derBeukatt commented on June 22, 2024

You are rigth. My messaging method is deprecated, thats why you couldnt compile the final version in your app. I gonna update it.
Did you use another firebase services in your app? What version are they?

I use FirebaseMessaging 7.1.0. That is the version installed by cocoapods.

Better! Do you wanna do a fork and send me this fix? Your name will be included as this project contributor.

Does this mean you experience the same problem after updating to the above version?
If so, I gladly provide the fix. Just don't want to break it for somebody else.

Prepared the pull request. You can decide if you want to merge. Thanks for your answers.

from awesome_notifications.

rafaelsetragni avatar rafaelsetragni commented on June 22, 2024

Im did not experienced this issue. For me, when i applied your changes, XCode complains about the override operation not being possible due to the different messaging method.

But send me your fork. This way i can merge your source and see every change that you did to figure out whats goin on.

from awesome_notifications.

rafaelsetragni avatar rafaelsetragni commented on June 22, 2024

In fact, ive merged your changes into my local files, and the messaging firebase method that you sent always complain about the override operation not being possible. In this way, i could not reproduce your error.

But i guess im figuring out whats going on. You said that youre using FirebaseMessaging 7.1.0, but you want to say firebase_messaging: ^7.1.0 instead?

This plugin is not necessary to send push notifications using awesome_notifications. All that you need is inside awesome_notifications plugin and you only need to follow the steps extrictely inside Using Firebase Services (Optional) topic. Is not necessary to use any other plugin or implement any kotlin or java extra script.

Maybe firebase_messaging version is conflicting with my awesome_notifications firebase library, because firebase_messaging is using another library version, that overides mine.

from awesome_notifications.

rafaelsetragni avatar rafaelsetragni commented on June 22, 2024

Bingo! That was exactely what happened!

image
image

After update my libraries with pod update, i got your error!

On the newer Firebase version, the firebase team did a lot of changes, including change the method messaging without keep a deprecated version. So, all the sources bellow 7.1.0 will break. And they also changed a lot of things on Android sdk, like making the entire FirebaseInstanceID obsolete.

(iOS) Version 7.1.0 - 11/10/2020
(Android) Cloud Messaging version 21.0.0

You got the newer firebase version after install a firebase plugin or update your pod files. Thats why you have those issues.

All the others awesome_notification developers gonna face the same after update the firebase package. So your change is entirely legit.

The problem that i facing is how to keep both methods working on the same time to not injure the olders projects.

Can you cancel the current pull request to master branch and send the same pull request to update-firebase-sdk branch instead? Theres a lot changes to do on Android side as well.

from awesome_notifications.

derBeukatt avatar derBeukatt commented on June 22, 2024

Yeah that is exactly what I was hoping was not happening.
But now that we now the problem it is maybe fixable.
If you need anything else from me, don't hesitate to ask. Thanks for your effort :)

Can you cancel the current pull request to master branch and send the same pull request to update-firebase-sdk branch instead? Theres a lot changes to do on Android side as well.

Consider it done :)

from awesome_notifications.

rafaelsetragni avatar rafaelsetragni commented on June 22, 2024

Ive merged your pull request and included a suport for older versions, as the code bellow. This way, both library versions are compatible with the core code being reusable:

    // For Firebase Messaging versions older than 7.0
    // https://github.com/rafaelsetragni/awesome_notifications/issues/39
    public func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
        
        didReceiveRegistrationToken(messaging, fcmToken: fcmToken)
    }
    
    public func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
        
        if let unwrapped = fcmToken {
            didReceiveRegistrationToken(messaging, fcmToken: unwrapped)
        }
    }
    
    private func didReceiveRegistrationToken(_ messaging: Messaging, fcmToken: String){
        
        print("Firebase registration token: \(fcmToken)")
        let dataDict:[String: String] = ["token": fcmToken]
        NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict)
    }

from awesome_notifications.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.