Gcm in Swift Bundle Id Error

GCM in Swift Bundle ID Error

Seems the Bundle ID in your GoogleService-Info.plist does not match the bundle ID in your target.

First you need to add the GoogleService-Info.plist file to a correct target, if you are trying the GcmExampleSwift, you should select that as the target:

Sample Image

Then in your GoogleService-Info.plist file, if you want to use com.XXXXXX.mobility.appfactory.dev1.social as your bundle ID, make sure you spell it correctly in for the BUNDLE_ID key:

Sample Image

Finally, in your targets, make sure you select the GcmExampleSwift first (NOT the GcmExample which is the Objective - C target), then make the the Bundle Identifier matches the BUNDLE_ID in your GoogleService-Info.plist file:

Sample Image

Unable to get configuration file for implementing Push Notification using GCM in iOS

I was exporting both certificate and key together to p12 (as it should be done). There was some issue with signing identities so after 7-8 tries, doing the same thing worked like a charm.

Getting 'unknown token' using GCM on iOS

Have you tried testing your push certification? Houston on GitHub is often used for certificate testing. Basically if the pushes don't work with the third party then you'll need to re-create your certificates.

Using Houston in Cli:

apn push "<5e8f5cc0 be283f88 cc4ebb7d b6091499 80f51631 5ebf4928 b59a2a62 198d20d0>" -c -out "apple_push_notification.pem" -m "Hello from the command line!"

*Houston says, *
We recommend that you upload development cert, production, and any ad-hoc certs. Layer will automatically determine which cert to use.

Other potential causes:

  • Are you correctly calling [layerClient updateRemoteNotificationDeviceToken...]?

  • Are you calling inside didRegisterForRemoteNotificationsWithDeviceToken to send Layer the device token?

You can also check to see if the app is failing to register by implementing didFailToRegisterForRemoteNotificationsWithError. If you look at the error you should be able to figure out why you're not seeing pushes.

Example Obj-C error check:

- (void) application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
NSLog(@"PUSH ERROR: %@", error);
}

Example Swift error check:

func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError!) {
print("PUSH ERROR: \(error)")
}

Potential Xcode/Certificate problem causes:

  • Provisioning profiles are not up-to-date. The device info is stored in the certificates so any time you add a new device to the profile you will need to re-create the profile and certificates.
  • Make sure that your XCode Project Settings is pointing the correct Certificate and Provisioning profile.
  • When inside the Keychain Access app make sure you are exporting the key AND the certificate.

GCM for iOS, gcm connection handler is never called

There are couple problems in your code.

First, you need to call GCMService.sharedInstance().startWithConfig(GCMConfig.defaultConfig()) in the didFinishLaunchingWithOptions method, but you only called it in didRegisterForRemoteNotificationsWithDeviceToken method.

Second, you should call application.registerForRemoteNotifications() after application.registerUserNotificationSettings() in your didFinishLaunchingWithOptions method.

There is a sample GCM project for iOS available, you can follow the sample implementation for AppDelegate.swift file, so that your app will work correctly.

You can also get the GCM iOS sample project via Cocoapods by doing pod try Google, you can visit this documentation for more details.

Edited:

You should replace the lines in your didFinishLaunchingWithOptions with the following (notice that you should use let gcmConfig = GCMConfig.defaultConfig() and gcmConfig.receiverDelegate = self):

    // [START_EXCLUDE]
// Configure the Google context: parses the GoogleService-Info.plist, and initializes
// the services that have entries in the file
var configureError:NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")
gcmSenderID = GGLContext.sharedInstance().configuration.gcmSenderID
// [END_EXCLUDE]
// Register for remote notifications
let settings: UIUserNotificationSettings =
UIUserNotificationSettings( forTypes: [.Alert, .Badge, .Sound], categories: nil )
application.registerUserNotificationSettings( settings )
application.registerForRemoteNotifications()
// [END register_for_remote_notifications]
// [START start_gcm_service]
var gcmConfig = GCMConfig.defaultConfig()
gcmConfig.receiverDelegate = self
GCMService.sharedInstance().startWithConfig(gcmConfig)
// [END start_gcm_service]
return true


Related Topics



Leave a reply



Submit