I am implementing the Pares iOS SDK but am unable to add new installs to the Data Browser. I have seemingly all the correct code and provisioning profiles. I am running iOS 8. What am I missing here?
****EDIT****
I have noticed that on older versions of iOS, devices do seem to be added.
You need to add the following function to your AppDelegate file.
func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
UIApplication.sharedApplication().registerForRemoteNotifications()
}
My attempt at rewriting it in Objective-C (it's been a while).
-(void) application:(UIApplication*) application didRegisterUserNotificationSettings: (UIUserNotificationSettings*) notificationSettings {
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
Related
When iOS 13 released, I opted out of using the new SceneDelegate through the normal procedures.
- SceneDelegate.swift does no longer exist
- There are no Scene related methods in AppDelegate
- Application Scene Manifest is removed from .plist
This worked great, and is how I've been running since (iOS 11.0 target, Xcode 11.2.1).
Last week I ran a build with deployment target as 13.0, then swapped back to 11.0.
Since then, the application delegate methods are no longer being called, such as.
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any])
The only thing that happens, that I can see is a log in console
Can't end BackgroundTask: no background task exists with identifier 15 (0xf), or it may have already been ended
I've triple checked all the settings above, but I can't get it to work like it used to.
The only thing that might be different is that the storyboards now defaults to 'automatic' (iOS 13.0, *) presentation mode, but I'm not sure how it was before.
Since automatic is only available from iOS 13+, it seems like something is messed up.
Does anyone have a clue?
Following up on the response in this thread:
applicationDidBecomeActive
applicationWillEnterForeground
etc are actually called.
I've tried cleaning the build, restarting Xcode, the mac, the device, clearing derived data etc.
So, I finally found the answer.
Turns out it's a good old
Instance Method Nearly Matches
func application(_ application: UIApplication, continue userActivity: NSUserActivity,
restorationHandler: #escaping ([UIUserActivityRestoring]?) -> Void) -> Bool
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool
That Xcode completely ignored to report, and somehow managed to break in between building for iOS 11 > iOS 13 > iOS 11.
It's also strange because I verified them a couple of days ago with the documentation, both Apples & Firebase, and there was no difference between them.
In the end, it works now, yay.
If you don't need want to use the SceneDelegate then add below property in the AppDelegate file.
var window: UIWindow?
Add this line above didFinishLaunchingWithOptions function
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
// Override point for customization after application launch.
return true
}
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)
}
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.
I followed all the steps correctly to install Firebase to my iOS App and it still doesn't work. In the application method, I added FIRApp.configure() like so:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
return true
}
And I keep receiving NSException errors. Firebase seems to work on my Android Project, what's the deal with iOS?
I believe this is some sort of Swift 3 issue, because I encountered a similar problem. After looking over the internet, I believe that Firebase 3 hasn't updated to recent Swift Syntax located in Swift 3. Many other developers are having trouble with it as well. As an alternative, you could switch back from Xcode 8 and into 7, which would allow you to create your application which will work with current IOS, and when Firebase updates, it will be easy for you to migrate to Swift 3.
Hope this helps,
Morgan Gallant
I have created an app which tracks the location of the user even if the app is in the background or the screen is locked. I have tested it on an iPhone 5s device with iOS 9.2 and everything was working fine. After updating to iOS 9.3.1 I noticed that the app would run for about 10 minutes in the background and then app would automatically stop. I updated the phone to iOS 9.3.2 yesterday hoping that there was a fix for this issue. However the issue still persists.
I have the following code in AppDelegate class
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
private static var backgroundService : BackgroundService? = nil
var startServices : Bool = false
public static var bgTask = UIBackgroundTaskIdentifier()
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
print("didFinishLaunchingWithOptions")
AppDelegate.bgTask = beginBackgroundUpdateTask()
startBackgroundService()
return true
}
internal func startBackgroundService(){
if AppDelegate.backgroundService == nil{
AppDelegate.backgroundService = BackgroundService.getBackgroundService()
}
AppDelegate.backgroundService!.startService(self)
}
internal func stopBackgroundService(){
AppDelegate.backgroundService!.stopService()
}
func beginBackgroundUpdateTask() -> UIBackgroundTaskIdentifier {
return UIApplication.sharedApplication().beginBackgroundTaskWithExpirationHandler({})
}
func applicationDidEnterBackground(application: UIApplication) {
self.startBackgroundService()
print("applicationDidEnterBackground")
}
}
Background App Refresh and Location Services have been enabled for the app on the iphone. Background mode has been enabled and other required permissions have been added in Info.plist.
The issue is not due to any code changes as I tested the code on another phone with iOS 9.2 and it is working perfectly. After updating the second phone to iOS 9.3.2 the same issue occurred. Has there been any change in 9.3 which is causing this issue? I went through the changelogs and documentation but haven't been able to find anything useful. Has anyone else encountered a similar issue? Is there any changes that I need to do to ensure that the app works with iOS 9.3?
Finally managed to solve the issue. After adding locationManager.allowsBackgroundLocationUpdates = true as suggested the issue still persisted. Although it ran in the background for a longer duration but after a certain point the app stopped fetching location data.
After searching online a bit more I came across this setting
locationManager.pausesLocationUpdatesAutomatically = false
Adding this line solved the issue and the location fetching works in the background without stopping abruptly. The default value for it is true.
As mentioned by #Ahmed and #Chajmz allowsBackgroundLocationUpdates is required in iOS 9 and later
In iOS 9 and later, regardless of deployment target, you must also set the allowsBackgroundLocationUpdates property of the location manager object to YES in order to receive background location updates. By default, this property is NO, and it should remain this way until a time when your app actively requires background location updates.
As per the documentation about CLLocationManager - pausesLocationUpdatesAutomatically
Allowing the location manager to pause updates can improve battery life on the target device without sacrificing location data. When this property is set to true, the location manager pauses updates (and powers down the appropriate hardware) at times when the location data is unlikely to change. For example, if the user stops for food while using a navigation app, the location manager might pause updates for a period of time.
The default value of this property is true.
Since iOS 9, you can avoid using backgroundTaskWithExpirationHandler, if you want to have constant access to your data from your LocationManager you can use allowsBackgroundLocationUpdates however, if you stop your LocationManager in background you won't be able to restart it from background.
if #available(iOS 9.0, *) {
manager.allowsBackgroundLocationUpdates = true
} else {
// Fallback on earlier versions
}