iOS device token not regenerated after migration from APN to firebase - ios

I created an APP for both iOS and Android and I used APN to get deviceToken for iOS and GCM for Android. I decided to migrate to firebase to make token management easier. I noticed a issue just for iOS application and I was wondering if someone else encountered it too.
When I migrated iOS app to firebase, token was not regenerated unless the app was reinstalled. I follow the firebase guide to do it but with no result.
Someone else has this problem?
Thanks in advance

I solved my problem.
I switch off and switch on capabilities
I restarted XCode
I put FIRInstanceIDAPNSTokenType to prod and now all seems to work
func application( _ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data ) {
FIRInstanceID.instanceID().token()
FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: FIRInstanceIDAPNSTokenType.prod)
}

Related

Flutter IOS app not receiving FCM notifications when deployed to test flight

I have a flutter app that i am trying to get Firebase cloud messaging to work on but for some reason it refuses to work when deploying to test flight.
If i run in debug mode through VSCode everything works as it should but as soon as i run flutter build ios and deploy to test flight everything breaks.
I have tried a multitude of solutions over the past couple of days including:
Removing and re-adding all certs & provisioning profiles
changing <key>FirebaseAppDelegateProxyEnabled</key><false/> to <key>FirebaseAppDelegateProxyEnabled</key><string>0<string/> AND to <key>FirebaseAppDelegateProxyEnabled</key><string>NO<string/>
trying to force the APNS token to be a production token by adding this to
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { #if DEVELOPMENT //Develop Messaging.messaging().setAPNSToken(deviceToken as Data, type: .sandbox) #else //Production Messaging.messaging().setAPNSToken(deviceToken as Data, type: .prod) #endif }
I have also tried doing different combinations of the above in the hope that one of the solutions would work in tandem with each other.
if anyone can shed some light on why this might be happening i would be extremely grateful!

url(forUbiquityContainerIdentifier) returns nil

I'm trying to get the url for my contrainer ID but the method keeps returning nil.
I've done the following:
Enabled iCloud Key-value storage in Xcode capabilities.
testing on a physical device.
iCloud, and iCloud Drive turned on in the physical device.
Made sure that iCloud Key-Value Store is added to the entitlements file.
My code is:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//Override point for customization after application launch.
let cloudURL = FileManager.default.url(forUbiquityContainerIdentifier: nil)
print(cloudURL as Any)
return false
}
I have looked for almost all of the questions that are related to this issue and tried the answers but it's not working.
For Xcode 9.2, checking this option worked:
iOS10.3
I had same problem, fix it by following steps:
1.go to physical device's setting -> iCloud. turn off iCloud Drive and turn it on again, find your app in iCloud Drive, turn off and turn on.
2.shut down your device, and restart it.
Then it worked, I'm not sure which part make it worked, hope for help.
Try this :
Inside the Settings app, under the 'iCloud' menu. I noticed that 'Documents & Data' was set to Off.
Solution was to change ('Documents & Data' to 'On'.

Firebase Push notifications not working

So my Firebase push notifications are not working on iOS (Simulator + I do not have a developer account, might this be already a reason?)
What I did:
Created an app in Google Firebase (I think I didn't add the fingerprint because I don't have it yet)
Added Firebase/FirebaseMessaging to my Podfile
Added GoogleService-Info.plist to my project Directory
Added Keychain Sharing in Capabilities
Added following code to my App Delegate:
Here is my code:
import Firebase
import UserNotifcations
import Firebase
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FIRApp.configure()
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.badge, .alert, .sound] {(granted, error) in}
application.registerForRemoteNotifications()
return true;
}
}
Any mistakes? Did I miss something? Is it because I don't have a developer account or is the simulator not capable of receiving push notifications? Any help would be appreciated!
Simulators in Xcode don't receive remote notifications. You have to run it on an actual device. I think Apple allow you to run it on a device without a paid developer account now.
You won' be able to send push notifications without a paid developer account. Not even on a real device.
More information here
The iOS simulator can't receive remote notifications. You have to run the app on your device.

Several push notifications being received with iOS

I'm working on an app that has push notifications enabled. My app it's using push notifications since day 1 with parse.com as the server.
Everything was working fine, I did several app updates and improvements and I had always receive one notification for each push sent by the server, I've also updated from parse 1.7.2 to 1.12.0 without having issues.
Because parse.com was going to terminate its services, I started the migration from parse to Urban Airship (using 7.0.2).
I did several tests, installing and uninstalling the app on my phone, installing the production version (using parse) and installing the development version (using urban airship), everything was working fine, when suddenly and I don't know why, I started receiving 5 notifications per push sent by the server. I thought it was a parse.com problem because at that time my iPhone was running the production version (with parse), but it was not.
When the version (using Urban Airship) was just published, I kept receiving 5 notifications.
I'm totally lost here, I don't have any clue why this is happening, at first I thought it was related with the several installs and uninstalls of the app, so I try:
1. Disabling notifications.-
2. Deleting the app.-
3. Disabling notifications
3.a. deleting the app
3.b. then changing time and date ahead a couple of days
3.c. then turning off the phone
3.d. turning on again and putting the right date
3.e. restarting the phone
3.f. installing the app
None of those worked so far. And I couldn't find anything online about this issue that was clear or solve this issue.
I hope someone could help me.
Extra info:
Swift 2
iOS 8.0+
XCode 7
Pushes are sent by a PHP Server
My AppDelegate.swift (Please notice that I have only included the relevant code, the rest of the code is not related):
import UIKit
import CoreData
import AirshipKit
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let config: UAConfig = UAConfig.defaultConfig()
UAirship.takeOff(config)
UAirship.push().userPushNotificationsEnabled = true
UAirship.push().resetBadge()
// Get the user settings
let userSettings = NSUserDefaults.standardUserDefaults()
var notify = userSettings.dictionaryForKey("notifications")
let appReset = userSettings.objectForKey("appResetv200")
if appReset == nil {
notify = nil
userSettings.setObject("done", forKey: "appResetv200")
}
if notify == nil {
let notificationTypes = [
"notType1" : true,
"notType2" : true,
"notType3" : true
]
userSettings.setObject(notificationTypes, forKey: "notifications")
UAirship.push().addTag("notType1")
UAirship.push().addTag("notType2")
UAirship.push().addTag("notType3")
UAirship.push().updateRegistration()
}
return true
}
}
I hope someone can help me, everything worked fine when I did the tests on my development environment, and now it's a complete mystery why it's failing.

New installations not appearing in Data Explorer - Parse.com

I deleted my installation class in the Parse Data Explorer, and created a new one. Now that it's empty no new installations are appearing in the class. What is causing this behaviour, and how can i fix it. Did Parse implement some kind of function to call in the iOS SDK before an installation can appear?
Any help is appreciated! :)
If you delete records from Installation table, the records will not appear again when you open your App. This easy fix is to delete the App from your device and re-install it for a device Installation record to appear again in your class. This is possibly because when you register an installation it gets cached locally by the Parse SDK on your device and will not be updated again.
I tried to do the push guide from Parse again, and it seemed like they changed some thing in the SDK, which caused the problem!
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
PFPush.storeDeviceToken(deviceToken)
let currentInstallation = PFInstallation.currentInstallation()
currentInstallation.setDeviceTokenFromData(deviceToken)
currentInstallation.channels = ["global"]
currentInstallation["notifyEnabled"] = true
currentInstallation.saveInBackground() //This line was not there initially!
}
I fixed it by inserting the line highlighted in the code.
Thanks for the all the help! :)

Resources