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. IOS - qiosapplicationdelegate.h linking problem in QtCreator

IOS - qiosapplicationdelegate.h linking problem in QtCreator

Scheduled Pinned Locked Moved Solved Mobile and Embedded
iosqt5.5.1
25 Posts 2 Posters 12.0k Views
  • 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.
  • V Offline
    V Offline
    Vi67
    wrote on last edited by
    #14

    Thx, I'm going to try that. Sounds good idea.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vi67
      wrote on last edited by
      #15

      I've tried something, but I have a bug during the execution of didRegisterForRemoteNotificationsWithDeviceToken function :

      -[QIOSApplicationDelegate gcmSenderID]: unrecognized selector sent to instance 0x13e524860
      *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[QIOSApplicationDelegate gcmSenderID]: unrecognized selector sent to instance 0x13e524860'
      

      There is the function :

      - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
          GGLInstanceIDConfig *instanceIDConfig = [GGLInstanceIDConfig defaultConfig];
          instanceIDConfig.delegate = self;
          [[GGLInstanceID sharedInstance] startWithConfig:instanceIDConfig];
          self.registrationOptions = @{kGGLInstanceIDRegisterAPNSOption:deviceToken, kGGLInstanceIDAPNSServerTypeSandboxOption:@YES};
          self.gcmSenderID = @"MYSENDERID";
          [[GGLInstanceID sharedInstance] tokenWithAuthorizedEntity:self.gcmSenderID scope:kGGLInstanceIDScopeGCM options:self.registrationOptions handler:self.registrationHandler];
      }
      

      There is the didFinishLaunchingWithOptions function :

      - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
          self.registrationKey = @"onRegistrationCompleted";
          self.gcmSenderID = @"MYSENDERID";
      
          // Register for remote notifications
          if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) { // iOS 7.1 or earlier
              UIRemoteNotificationType allNotificationTypes = (UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge);
              [application registerForRemoteNotificationTypes:allNotificationTypes];
          } else { // iOS 8 or later
              UIUserNotificationType allNotificationTypes = (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
              UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
              [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
              [[UIApplication sharedApplication] registerForRemoteNotifications];
          }
          
          
          __weak typeof(self) weakSelf = self;
      
          // Handler for registration token request
          self.registrationHandler = ^(NSString *registrationToken, NSError *error) {
              if (registrationToken != nil) {
                  weakSelf.registrationToken = registrationToken;
                  NSLog(@"Registration Token: %@", registrationToken);
                  //[weakSelf subscribeToTopic];
                  NSDictionary *userInfo = @{@"registrationToken":registrationToken};
                  [[NSNotificationCenter defaultCenter] postNotificationName:weakSelf.registrationKey object:nil userInfo:userInfo];
              } else {
                  NSLog(@"Registration to GCM failed with error: %@", error.localizedDescription);
                  NSDictionary *userInfo = @{@"error":error.localizedDescription};
                  [[NSNotificationCenter defaultCenter] postNotificationName:weakSelf.registrationKey object:nil userInfo:userInfo];
              }
          };
          return YES;
      }
      
      1 Reply Last reply
      0
      • V Offline
        V Offline
        Vi67
        wrote on last edited by
        #16

        According to this stackoverflow post, I should use the gstatic version of GCM.
        I don't have an iphone for testing now, I'll test tonight.

        1 Reply Last reply
        0
        • V Offline
          V Offline
          Vi67
          wrote on last edited by
          #17

          I tried without GCM service or GoogleService-Info.plist, but i haven't good results.

          Then I came back to GoogleService-Info.plist loading problem.
          Before I got this error :
          Could not locate configuration file: 'GoogleService-Info.plist'.
          But now, I have a better error :
          The configuration file is not a dictionary: 'GoogleService-Info.plist'.
          It looks better, isn't it ? :D .. but it still doesn't work

          There is the fix in .pro file :

          GInfo.files = ios/GoogleService-Info.plist
          GInfo.path = GoogleService-Info.plist
          
          QMAKE_BUNDLE_DATA += GInfo
          
          1 Reply Last reply
          0
          • L Offline
            L Offline
            Leonardo
            wrote on last edited by Leonardo
            #18

            I don't get your code. I can compile successfully without GCM service. Here's a simplified version of my code:

            -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
            
            	GGLInstanceIDConfig* idConfig = [GGLInstanceIDConfig defaultConfig];
            	
            	idConfig.delegate = self;
            	
            	[[GGLInstanceID sharedInstance] startWithConfig:idConfig];
            	
            	//====================================
            	
            	if([application respondsToSelector:@selector(registerForRemoteNotifications)]){
            		[application registerForRemoteNotifications];
            	}else{
            		[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert];
            	}
            	
            	return YES;
            	
            }
            
            -(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
            
            	GGLInstanceID* idInstance = [GGLInstanceID sharedInstance];
            
            	[idInstance tokenWithAuthorizedEntity:@"123456789"
            									scope:kGGLInstanceIDScopeGCM
            								  options:@{kGGLInstanceIDRegisterAPNSOption : deviceToken, kGGLInstanceIDAPNSServerTypeSandboxOption : @0}
            								  handler:^(NSString *token, NSError *error) {
            
            									  if(token != nil){
            
            										  // 
            
            									  }
            
            								  }];
            
            }
            
            1 Reply Last reply
            0
            • V Offline
              V Offline
              Vi67
              wrote on last edited by Vi67
              #19

              Thx to share your code.
              It's simpler than the Google sample.

              I'm just wondering what is the difference between putting startWithConfig in didFinishLaunchingWithOptions as you did, or put it in didRegisterForRemoteNotificationsWithDeviceToken as it's done in Google sample ?

              I guess it's working, I just have this error, because I'm working on simulator :
              Registration for remote notification failed with error: REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION

              I wait the device to make the final test.

              1 Reply Last reply
              0
              • V Offline
                V Offline
                Vi67
                wrote on last edited by
                #20

                Hello Leonardo,

                Now GCM service is working fine for 2 ouf of 3 cases :

                • When the app is active -> OK

                • When the app is in background, then I click on the notif popup (in IOS UI), then the app comes back -> OK

                • But for the last case, there is a bug :
                  The app is closed. Then a notif popup is comming (in IOS UI), but when I click on it -> The app isn't shown back. The phone is almost blocked. It looks like the app is running in background but with a blackscreen. I don't even know how to have a log trace, because the app was previously closed manually.

                I hope you can help me again. Any way, I'm reaching the end through your help.

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  Leonardo
                  wrote on last edited by
                  #21

                  Hi. Soon I'll be performing some tests on a real device also. I'll let you know about my results.

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    Vi67
                    wrote on last edited by
                    #22

                    Ok, then I'm waiting your test.
                    I found that we can launch a qt project from xcode. With this method, I may have a better log trace (specially when the first execution is killed). I will have a look on that.

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      Leonardo
                      wrote on last edited by
                      #23

                      Hi. It worked in all three cases for me. The only time I could reproduce the issue you mentioned was when I launched the app from XCode and then closed it manually on the device. An error was thrown on XCode and the app was like suspended. In that case indeed it felt like the device was frozen, but it was so just because XCode was holding the app.

                      1 Reply Last reply
                      0
                      • V Offline
                        V Offline
                        Vi67
                        wrote on last edited by
                        #24

                        Thanks for your test.
                        You are right, I closed manually the app. I didn't know that xcode or qt holds the app.
                        Now everything looks great. I just need to check if the third case code is working, I have something like that :

                        - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
                        
                        if (launchOptions != nil) {
                            NSDictionary* notif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
                            if (notif) {
                                NSString* type_n = [notif valueForKey:@"gcm.notification.type"];
                                if (type_n) {
                                    std::string* type = new std::string([type_n UTF8String]);
                                    MyNotif::setExtraType(type);
                                }
                            }
                        }
                        ...
                        }
                        
                        1 Reply Last reply
                        0
                        • L Offline
                          L Offline
                          Leonardo
                          wrote on last edited by
                          #25

                          Hi. I don't think you need to check for the notification type, because there will be no other one. Anyway, be careful, because didFinishLaunchingWithOptions will run before your main() from Qt. It means that even QApplication won't be available by then.

                          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