Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Use Firebase SDK on iOs (push notifications)
Forum Updated to NodeBB v4.3 + New Features

Use Firebase SDK on iOs (push notifications)

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 6 Posters 4.2k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Schluchti
    wrote on last edited by Schluchti
    #1

    Hi,

    has someone of you successfully used the Firebase SDK for integrating push notifications? I mostly followed this guide here: https://github.com/firebase/quickstart-ios/blob/master/messaging/MessagingExample/AppDelegate.m

    The relevant parts are looking like this:

    my AppDelegate:

    #import "FirebaseInstanceID.h"
    #import "FirebaseMessaging.h"
    #import "FirebaseAnalytics.h"
    #import <FIRApp.h>
    
    @interface QIOSApplicationDelegate
    @end
    //add a category to QIOSApplicationDelegate
    @interface QIOSApplicationDelegate (QPushNotificationDelegate)
    @end
    
    (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    // Register for remote notifications. This shows a permission dialog on first run, to
            // show the dialog at a more appropriate time move this registration accordingly.
            if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) {
                // iOS 7.1 or earlier. Disable the deprecation warnings.
    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wdeprecated-declarations"
                UIRemoteNotificationType allNotificationTypes =
                (UIRemoteNotificationTypeSound |
                 UIRemoteNotificationTypeAlert |
                 UIRemoteNotificationTypeBadge);
                [application registerForRemoteNotificationTypes:allNotificationTypes];
    #pragma clang diagnostic pop
            } else {
                // iOS 8 or later
                // [START register_for_notifications]
                if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
                    UIUserNotificationType allNotificationTypes =
                    (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
                    UIUserNotificationSettings *settings =
                    [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
                    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
                }
    
    [[UIApplication sharedApplication] registerForRemoteNotifications];
                // [END register_for_notifications]
            }
    // [START configure_firebase]
        [FIRApp configure];
        // [END configure_firebase]
        // Add observer for InstanceID token refresh callback.
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshNotification:)
                                                     name:kFIRInstanceIDTokenRefreshNotification object:nil];
    }
    

    my *.pro file:

    MAKE_LFLAGS += -F$$PWD/ext/libraries/ios/Firebase/Analytics
        QMAKE_LFLAGS += -F$$PWD/ext/libraries/ios/Firebase/Messaging
        QMAKE_LFLAGS += -ObjC
    
    
        INCLUDEPATH += $$PWD/ext/libraries/ios/Firebase/Analytics/FirebaseAnalytics.framework/Headers
        INCLUDEPATH += $$PWD/ext/libraries/ios/Firebase/Analytics/FirebaseInstanceID.framework/Headers
        INCLUDEPATH += $$PWD/ext/libraries/ios/Firebase/Messaging/FirebaseMessaging.framework/Headers
        INCLUDEPATH += $$PWD/ext/libraries/ios/Firebase/Analytics/FirebaseCore.framework/Headers
        LIBS +=-framework FirebaseAnalytics
        LIBS +=-framework FirebaseCore
        LIBS +=-framework FirebaseInstanceID
        LIBS +=-framework GoogleInterchangeUtilities
        LIBS +=-framework GoogleSymbolUtilities
        LIBS +=-framework GoogleUtilities
        LIBS +=-framework FirebaseMessaging
        LIBS +=-framework GoogleIPhoneUtilities
        LIBS +=-framework AddressBook
        LIBS += -lsqlite3
    

    Unfortunately I always get:

    Use of undeclared identifier FIRApp
    

    when compiling. Does anyone have an idea on how to fix that?

    Want to read more about Qt?

    https://gympulsr.com/blog/qt/

    Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

    1 Reply Last reply
    0
    • GTDevG Offline
      GTDevG Offline
      GTDev
      wrote on last edited by
      #2

      Hi!

      V-Play Engine offers several plugins for integrating push notifications in your Qt app, for example with the Google Cloud Messaging service.
      A Firebase plugin is currently being implemented and will be coming soon as well.

      Best,
      GT

      Senior Developer at Felgo - https://felgo.com/qt

      Develop mobile Apps for iOS & Android with Qt
      Felgo is an official Qt Technology Partner

      1 Reply Last reply
      -1
      • D Offline
        D Offline
        Danh Phan
        wrote on last edited by Danh Phan
        #3

        Here is my solution:
        Create a directory "ios/CocoaPods" inside root path of the Qt Project
        Create inside this directory an Xcode project "Empty" (just autogenerate a single view iOS project with Xcode and save here)
        Create a file "Podfile" with the following content:
        target 'Empty' do
        pod 'Firebase/Core'
        pod 'Firebase/Auth'
        pod 'Firebase/Messaging'
        pod 'Firebase/Database'
        pod 'Firebase/Crash'
        end

        Run "pod install"; and inside the "CocoaPods" there will be a directory "Pods" with generated Frameworks.
        In your .pro add the following lines to include frameworks:
        LIBS += -F$$PWD/ios/CocoaPods/Pods/FirebaseCore/Frameworks -framework FirebaseCore \
        -F$$PWD/ios/CocoaPods/Pods/FirebaseAnalytics/Frameworks -framework FirebaseAnalytics \
        -F$$PWD/ios/CocoaPods/Pods/FirebaseAuth/Frameworks -framework FirebaseAuth \
        -F$$PWD/ios/CocoaPods/Pods/FirebaseCrash/Frameworks -framework FirebaseCrash \
        -F$$PWD/ios/CocoaPods/Pods/FirebaseDatabase/Frameworks -framework FirebaseDatabase \
        -F$$PWD/ios/CocoaPods/Pods/FirebaseInstanceID/Frameworks -framework FirebaseInstanceID \
        -F$$PWD/ios/CocoaPods/Pods/FirebaseMessaging/Frameworks -framework FirebaseMessaging

        INCLUDEPATH += $$PWD/ios/CocoaPods/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers \
        $$PWD/ios/CocoaPods/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers \
        $$PWD/ios/CocoaPods/Pods/FirebaseAuth/Frameworks/FirebaseAuth.framework/Headers \
        $$PWD/ios/CocoaPods/Pods/FirebaseCrash/Frameworks/FirebaseCrash.framework/Headers \
        $$PWD/ios/CocoaPods/Pods/FirebaseDatabase/Frameworks/FirebaseDatabase.framework/Headers \
        $$PWD/ios/CocoaPods/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Headers \
        $$PWD/ios/CocoaPods/Pods/FirebaseMessaging/Frameworks/FirebaseMessaging.framework/Headers
        XCODE_EXTRAS.files = ios/GoogleService-Info.plist
        QMAKE_BUNDLE_DATA += XCODE_EXTRAS

        1 Reply Last reply
        1
        • W Offline
          W Offline
          Walter_Ponk
          wrote on last edited by
          #4

          The Zetpush https://zetpush.com/ is an option for push notifications.

          1 Reply Last reply
          0
          • SnowGrainsS Offline
            SnowGrainsS Offline
            SnowGrains
            wrote on last edited by
            #5

            Hi there,

            I am currently contributing QtCloudMessaging API wrapper to Qt. Its helping developers to use push notification services in easy way. There are two services integrated: Firebase and Kaltiot embedded backends. Those two also gives example how one can extend new services behind the wrapper.

            Repository is currently under preview, but has gone through multiple review rounds already and is functional. To get started do following:

            1. Clone repo
              git clone https://codereview.qt-project.org/qt/qtcloudmessaging

            2. Get latest patch:
              git fetch https://codereview.qt-project.org/qt/qtcloudmessaging refs/changes/55/202155/28 && git checkout FETCH_HEAD

            3. Install and compile repo to your platform. Check readme instructions.
              qmake CONFIG+="firebase"
              make
              make install

            4. Check example app for Firebase (detailed instructions in readme there) and embedded devices from: https://github.com/snowgrains/qtcloudmessaging-examples

            4.1 The pod file install for firebase needs few tweaks for Qt-generated xcode project file, but with following commands (or added in .sh file) you can easily tweak it. Run these with terminal inside .xcodeproj folder (right click + Show Package Contents):
            sed -i '' '/refType = 0;/d' ./project.pbxproj
            sed -i '' '/name = "Compile Sources";/d' ./project.pbxproj
            sed -i '' '/name = "Link Binary With Libraries";/d' ./project.pbxproj
            sed -i '' '/name = "Copy Bundle Resources";/d' ./project.pbxproj
            sed -i '' '/buildRules = (/ { N; d; }' ./project.pbxproj*

            Tell me if you encounter any problems.

            Uncle_MastaU 1 Reply Last reply
            0
            • SnowGrainsS SnowGrains

              Hi there,

              I am currently contributing QtCloudMessaging API wrapper to Qt. Its helping developers to use push notification services in easy way. There are two services integrated: Firebase and Kaltiot embedded backends. Those two also gives example how one can extend new services behind the wrapper.

              Repository is currently under preview, but has gone through multiple review rounds already and is functional. To get started do following:

              1. Clone repo
                git clone https://codereview.qt-project.org/qt/qtcloudmessaging

              2. Get latest patch:
                git fetch https://codereview.qt-project.org/qt/qtcloudmessaging refs/changes/55/202155/28 && git checkout FETCH_HEAD

              3. Install and compile repo to your platform. Check readme instructions.
                qmake CONFIG+="firebase"
                make
                make install

              4. Check example app for Firebase (detailed instructions in readme there) and embedded devices from: https://github.com/snowgrains/qtcloudmessaging-examples

              4.1 The pod file install for firebase needs few tweaks for Qt-generated xcode project file, but with following commands (or added in .sh file) you can easily tweak it. Run these with terminal inside .xcodeproj folder (right click + Show Package Contents):
              sed -i '' '/refType = 0;/d' ./project.pbxproj
              sed -i '' '/name = "Compile Sources";/d' ./project.pbxproj
              sed -i '' '/name = "Link Binary With Libraries";/d' ./project.pbxproj
              sed -i '' '/name = "Copy Bundle Resources";/d' ./project.pbxproj
              sed -i '' '/buildRules = (/ { N; d; }' ./project.pbxproj*

              Tell me if you encounter any problems.

              Uncle_MastaU Offline
              Uncle_MastaU Offline
              Uncle_Masta
              wrote on last edited by
              #6

              @SnowGrains I saw this mentioned in the blog (http://blog.qt.io/blog/2018/01/02/qt-cloud-messaging-api-available-embedded-systems/), but the URL for cloning is invalid, even just two weeks after that blog post. What happened?

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved