iOS13 can't support the background update notification? - ios13

iOS13 can't support the background update notification.Is this an OS-level bug?
And when app enter background,the Xcode warning shows:
Can't end BackgroundTask: no background task exists with identifier 1
(0x1), or it may have already been ended. Break in
UIApplicationEndBackgroundTaskError() to debug.

I have got the answer from the Developer Documentation:
https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns
apns-push-type
(Required when delivering notifications to devices
running iOS 13 and later, or watchOS 6 and later. Ignored on earlier
system versions.) The type of the notification. The value of this
header is alert or background. Specify alert when the delivery of your
notification displays an alert, plays a sound, or badges your app's
icon. Specify background for silent notifications that do not interact
with the user.

Related

How can I disable the Android 11 media notification for my application when using ExoPlayer's media2 extension?

I have an application that plays videos using ExoPlayer. A notification is created using the PlayerNotificationManager and MediaDescriptionAdapter from ExoPlayer.
On Android 11 on a Pixel 5 (but not a Pixel 3 XL) or any Samsung device I see two notifications: one that I see on all other OS versions, and one that appears in the settings tray on a Pixel, or the Media section (and lock screen) on Samsung devices.
At some point, I would like to support that notification properly, but for now, having two notifications is a bug, and it seems like the easiest fix should be to disable the new notification.
The linked documentation says
To be discoverable your app must provide a MediaBrowserService, typically using the MediaBrowserServiceCompat library from Android Jetpack.
My app has an androidx.media2.MediaSessionService, which hides the MediaBrowserService. I have tried returning null from the onGetSession() method, but the notification still appears. It seems like I need a way to do the equivalent of returning null from onGetRoot().
Is there anything I can do to opt out of this notification without rewriting all of my MediaSession/MediaSessionService code to use the older compat equivalents?

When is sessionReachabilityDidChange(_:) called on a watch WCSessionDelegate?

Apple's documentation says this in the discussion section of the method description:
This method is called to let the
current process know that its counterpart session’s reachability
changed.
The description of the isReachable property says this: WatchKit
extension. The iOS device is within range, so communication can occur
and the WatchKit extension is running in the foreground, or is running
with a high priority in the background (for example, during a workout
session or when a complication is loading its initial timeline data).
I am assuming this would mean that if the watch moves out of or into range of the iOS device, the WatchKit extension would be launched and the WCSessionDelegate's sessionReachabilityDidChange() method would be called, and the WCSession's isReachable would be true if the iOS device just came into range and false if it just when out of range.
I have not found a way to verify this in xcode. For example I put a log message in sessionReachabilityDidChange(_:) and walked out of range, but xcode simply says the app lost connection with the iphone and can no longer debug it. Can someone verify this or point me to some documentation that better describes this?
I think you cannot verify this in Xcode.
I have an app on iOS and watchOS. To check this kind of situation, I can enable debug alerts on iOS and watchOS. When func sessionReachabilityDidChange(session: WCSession) is triggered, I display a debug alert.
Now, if I run (not under Xcode) my watch extension, and then switch off the paired iPhone, the debug alert is shown on the watch.
This shows that sessionReachabilityDidChange is actually called as expected.
Apparently, under Xcode a connected iOS device is always reachable.
EDIT:
To check the situation when the watch extension is not in foreground, I did the following:
Instead of showing a debug alert, I set now the complication to a unique value that is not possible otherwise. I launched the watch extension and put it into background by showing the watch face with the complication.
When I now switch off the iPhone, the complication is not updated.
This indicates to me that sessionReachabilityDidChange is not called in background.

iOS 13 Schedule iOS background tasks

I am implementing BackgroundTasks Framework for updating the data. But I got the below issue
Could not schedule refreshApp: Error Domain=BGTaskSchedulerErrorDomain Code=1 "(null)"
Could not schedule data featch: Error Domain=BGTaskSchedulerErrorDomain Code=1 "(null)"
2019-10-01 19:19:32.550320+0530 SOBackgroundTask[34131:1129470] Can't end BackgroundTask: no background task exists with identifier 3 (0x3), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
Here are possible error codes for Domain=BGTaskSchedulerErrorDomain extracted from ObjC headers with some explanation.
BGTaskSchedulerErrorCodeUnavailable = 1 // Background task scheduling functionality is not available for this app/extension. Background App Refresh may have been disabled in Settings.
BGTaskSchedulerErrorCodeTooManyPendingTaskRequests = 2 // The task request could not be submitted because there are too many pending task requests of this type. Cancel some existing task requests before trying again.
BGTaskSchedulerErrorCodeNotPermitted = 3 // The task request could not be submitted because the appropriate background mode is not included in the UIBackgroundModes array, or its identifier was not present in the BGTaskSchedulerPermittedIdentifiers array in the app's Info.plist.
The solution is to run on a device. I was running on a simulator. However, It was showing the Background App Refresh has been enabled in Settings while running on the simulator.
There may be some other reasons. Please visit
https://developer.apple.com/documentation/backgroundtasks/bgtaskschedulererrorcode/bgtaskschedulererrorcodeunavailable?language=objc
For:
BGTaskSchedulerErrorDomain error 3
Check inside the project’s .xcodeproj file for the appropriate target. Then go to the info tab and Custom iOS Target Properties and check that the permitted background task scheduler identifiers (BGTaskSchedulerPermittedIdentifiers) are added.
This solved my problem when adding BackgroundTasks to an existing project.
Please check if you miss registering BGTaskSchedulerPermittedIdentifiers in info.plist file of your project.
I have tested on real device(iOS13.2, and iOS13.2.2), but it's same result.
Error Domain=BGTaskSchedulerErrorDomain Code=2 "(null)"
Can't end BackgroundTask: no background task exists with identifier 37 (0x25), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
Error Domain=BGTaskSchedulerErrorDomain Code=1 "(null)"
Can't end BackgroundTask: no background task exists with identifier 113 (0x71), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
It seems that there is still exist bug.
https://forums.developer.apple.com/thread/121990
I think this is because that your mobile turn the bg refresh off!!!!!!!
In case of BGTaskSchedulerErrorDomain error 3, I didn't add below
<array>
<string>com.shiny.job</string>
<string>com.shiny.jobpower</string>
<string>com.shiny.jobnet</string>
<string>com.shiny.jobpowernet</string>
</array>```
Just check the Background Modes has been added to the target Capabilities and that Background fetch and Background processing options are selected
According to https://developer.apple.com/documentation/backgroundtasks/bgtaskschedulererrorcode/bgtaskschedulererrorcodeunavailable?language=objc, this error usually occurs for one of three reasons:
The user has disabled background refresh in settings.
The app is running on Simulator which doesn’t support background
processing.
The keyboard extension either hasn’t set RequestsOpenAccess to YES in
The Info.plist File, or the user hasn’t granted open access.
The extension type isn’t able to schedule background tasks.
check you Appdelegate.swift is including WorkmanagerPlugin.registerTask(withIdentifier: "your.task.id")

HKWorkoutSession isn't keeping app at front of Apple Watch

It has been stated that an app running a HKWorkoutSession will have special privileges over other watchOS 2 apps, so when a user looks at their Apple Watch, it will go to the view showing running a workout rather than the watch face.
Currently, on both my device and simulator, this is not the case. If I start a HKWorkoutSession and then leave for 5 minutes and then interact with either the Apple Watch, or the Watch Simulator, it presents the watch face.
If I then open my app, it appears to have been frozen, rather than terminated (which is what I imagine happens to other apps). As the UI will update when I need receive a response in my query.updateHandler. Also if I set it to provide haptic feedback every time my query.updateHandler receives a new HKQuantitySample it will do so, so the app must be running in the background in some form.
Has anyone else noticed this behaviour, and am I doing anything wrong, or expecting something I shouldn't?
Here is how I start my HKWorkoutSession:
self.workoutSession = HKWorkoutSession(activityType: HKWorkoutActivityType.Other, locationType: HKWorkoutSessionLocationType.Indoor)
self.healthStore.startWorkoutSession(self.workoutSession) {
success, error in
if error != nil {
print("startWorkoutSession \(error)\n")
self.printLabel.setText("startWorkoutSession \(error)")
self.printLabel.setTextColor(UIColor.redColor())
}
We're seeing that too, for the moment we've made sure 'opens last activity' is configured.
When the UI is active we start a dispatch_timer to request and process data in 1 second intervals.
Make sure you do any significant processing using the NSUserProcessInfo method though and pause the dispatch_timers whenever you are no longer active. You'll get crashes otherwise.

Apigee BaaS emails me weird error messages

I am using Apigee BaaS and everytime I run the cordova app that consumes these apis I get this error message in an email
[org-name-app-name timeStamp Sat Dec 27 19:52:03 UTC 2014][ Tag : CRASH][ Device Platform : android][ Platform Version : android UNKNOWN][ Device Model : UNKNOWN][ Devicd ID :794DCBC2-4D1D-9EEC-A86560412878]Error:[object Event] for url:undefined on line:undefined
What exactly is this? Why do I get this?
Apigeee BaaS SDKs also include App Performance Monitoring (APM) functionalities. APM catches crashes in iOS and Android Apps. When it comes to JS, it captures all errors and will send email notification in group depending on how frequently errors/crashes are happening and some configuration parameters. If you don't want to get notification, then you can turn off entire APM or just crash notification. To disable monitoring completely, see http://apigee.com/docs/app-services/content/monitoring-app-usage-data . Just to suppress crash notification, see http://apigee.com/docs/app-services/content/monitoring-app-errors-and-crashes section "Disabling alert.."

Resources