Run Api code after killed the App iOS flutter -Background fatch- plugins - ios

after run the simulate Background fetch I see That in the log.
I tested using. real device iPhone 8 - iOS 13.4.1
I waited two days nothing happened.
The log:
2020-05-29 18:05:53.515643+0300 Runner[372:40553] [TSBackgroundFetch scheduleProcessingTask]
2020-05-29 18:05:53.523393+0300 Runner[372:40553] [TSBackgroundFetch finish] flutter_background_fetch (2 of 2)
🔵-[BackgroundTaskManager startPreventSuspendTimer:] BG time remaining: 20 | Total tasks: 1
2020-05-29 18:05:54.032876+0300 Runner[372:40857] 🔵-[BackgroundTaskManager startPreventSuspendTimer:] BG time remaining: 20 | Total tasks: 1
🔵-[TSLocationManager onSuspend:] enabled? 1)

If the user kills your app, nothing further will happen in the background. I take "kill" to mean a hard, force quit. Merely hitting the Home button sends your app to the background.
Can't you just send you a note when the appDelegate receives a "applicationWillTerminate" or a "applicationWillResignActive"?

Related

Background Service in Appcelerator titanium for iOS

I am facing some problem in background service.I have registered the backgrond service like:var service = Ti.App.iOS.registerBackgroundService({url:'/bgservice.js'});
in bgservice.js :I actually want to check the DB(where the data execution time is>8mins) and trigger local notification.But it is not working.So tried a sample first like this,to see how much time the app is active in background:
var timer = setInterval(startsampletest, 6000);
startsampletest();
function startsampletest(){
count=count+1;
Ti.API.info("1.!!!!!*******startsampletest is called for"+count);
}
which gives me only 5 times every 6 seconds so it is executing only for 30 min(please correct me if I am wrong)But in axway documentation it says the bgservice will be active for 10 mins.
Can anyone pls help me on this.I want the app to be active in background for 10 mins.pls let me know if I have made any mistakes.
It is not guaranteed that a background task created by Ti.App.iOS.registerBackgroundService() will run up to 10 minutes,
see: https://titaniumsdk.com/api/titanium/app/ios/backgroundservice.html#background-service-limitations
... typically to no more than 10 minutes.
But more crucial is that
The OS may terminate the background service at any point to reclaim resources.
For longer background tasks under iOS you have to use
the Ti.URLSession module (com.appcelerator.urlSession).
In general, see https://titaniumsdk.com/guide/Titanium_SDK/Titanium_SDK_How-tos/Platform_API_Deep_Dives/iOS_API_Deep_Dives/iOS_Background_Services.html

Xcode 12 quit unexpectedly in Mac OS 10.15.4

Xcode 12 quit unexpectedly in Mac OS 10.15.4.
The document “Main.storyboard” had an issue that was found and repaired.
This may be due to an SCM operation such as merging. Please save the document to fix the issue.
Multiple resources have the same name: groupTableViewBackgroundColor.
Date/Time: 2020-09-26 08:18:54 +0530
End time: 2020-09-26 08:26:49 +0530
OS Version: Mac OS X 10.15.4 (Build 19E266)
Architecture: x86_64h
Report Version: 29
Data Source: Stackshots
Shared Cache: 0x2fb4000 01EE95E0-91B0-354A-BD0A-C761305CD75D
Command: Xcode
Path: /Applications/Xcode 12.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 12.0 (17219)
Build Version: 2
Product Build Version: 12A7209
Project Name: IDEFrameworks
Source Version: 17219000000000000
Parent: launchd [1]
PID: 2432
Event: hang
Duration: 475.00s
Duration Sampled: 1.99s (process was unresponsive for 473 seconds before sampling)
Steps: 20 (100ms sampling interval)
Hardware model: MacBookAir7,2
Active cpus: 4
Time Awake Since Boot: 5700s
Fan speed: 1234 rpm
--------------------------------------------------
Timeline format: stacks are sorted chronologically
Use -i and -heavy to re-report with count sorting
--------------------------------------------------
Heaviest stack for the main thread of the target process:
20 <truncated backtrace>
20 __psynch_mutexwait + 10 (libsystem_kernel.dylib + 12386) [0x7fff6a22a062]
*20 psynch_mtxcontinue + 0 (pthread + 9566) [0xffffff7f82d6e55e]
Process: Xcode [2432]
UUID: BEF84410-992D-3871-AD2A-C8C9AB4BD25C
Path: /Applications/Xcode 12.app/Contents/MacOS/Xcode
Architecture: x86_64
Parent: launchd [1]
UID: 501
Sudden Term: Tracked
Footprint: 490.54 MB
Start time: 2020-09-26 08:26:47 +0530
End time: 2020-09-26 08:26:48 +0530
Num samples: 20 (1-20)
CPU Time: 0.022s (52.9M cycles, 37.5M instructions, 1.41c/i)
Note: Unresponsive for 473 seconds before sampling
Note: 4 idle work queue threads omitted
I had exactly the same problem.
Good news, I found the solution!
Short story:
You need to find the Views that have tableCellGroupedBackgroundColor as their color and change it.
tip: This color was used by the tableView cells as a background color, look there first.
Long story:
After updating to Xcode 12.2 every time I opened Main.storyboard, the same message was displayed as yours.
Assuming it is a color incompatibility (tableCellGroupedBackgroundColor in our case), I opened Main.storyboard as Source Code (right click on the Main.storyboard -> Open As -> Source Code) and searched for "tableCellGroupedBackgroundColor".
I noticed that this color appeared several times in the "resources" at the end of the file, while it should appear only once.
This is probably why Xcode displays the error message.
Looking above, I noticed that the specific color was in the background color in tableView cells.
So I reopened Main.storyboard as Interface Builder (right click on the Main.storyboard -> Open As -> Interface builder-Storyboard) and changed the background color in all tableView cells to Default.
pro tip: You can delete the colors from the Source code directly, by deleting the lines that refers the colors to the Views.
That's it!
After that everything works perfectly again!
I have a similar issue with additional infos. In xCode 12, and 12.2 beta, my main storyboard appear after many minutes and I get:
The document “Main.storyboard” had 15 issues that were found and repaired.
The save popup also shows:
This may be due to an SCM operation such as merging. Please save the document to fix the issues.
The errors are of 3 types for me:
1- Multiple resources have the same name: darkTextColor.
2- Multiple resources have the same name: groupTableViewBackgroundColor.
3- Multiple resources have the same name: tableCellGroupedBackgroundColor.
It asks to save in order to repair but it does not repair at all.
There are no warning in the environment either before or after the save.
When the project finally loads, if I edit it for a while then it stops responding and I have to force xCode to quit. If I load my app in xCode 11.7 it shows instantly and work fine. If one of our users upgrades to IOS14 with the working version of the app it crashes in some views however if I compile with xCode12, even with storyboard file that I cannot open, and I publish on IOS14 the apps work well and the broken views shows up.
When I debug in xCode 12 and navigate to a broken view the app/xCode stops but no warning or error are displayed. I tried to change and remove this line in the storyboard file without success:

How can I get location from background?

My problem is:
Save the user's location every 1 minute and after 15 minutes, push it to the server once. My approach is to create an underground thread. After 1 minute, call the function to save into sqlite 1 time. But how to run the function every 1 minute, in case the application is in the background then how to handle it.
I found the plugin: background_fetch.
But it takes at least 15 minutes to run once.
I've try this and it's working foreground & background (but not terminated):
background_location

Altbeacon - Samsung Galaxy s9 not ranging beacons as expected when locked and power cable unplugged

I'm using the Altbeacon library and implementing the foreground service to allow for faster ranging. My app is designed to send a notification to the user whenever a matching beacon is ranged. The goal is that this happens no matter what, phone locked, unlocked, app open, app closed, and app cleared from task manager.
The app works as expected with a Samsung Galaxy s7 running Android 8.0. The issue I'm experiencing with the Samsung Galaxy s9 running Android 8.0, is when the power button is pressed to lock the phone. The phone no longer receives the notifications as often as it should, as if the foreground beacon scanning is being blocked.
The device sending the beacons can transmit a new beacon continuously at a 25ms rate for 12 seconds, for testing purposes, at the end of the 12 seconds it is set to repeat that process. The user should receive a new notification every 12 seconds, however the s9 may only receive 1 notification and then 5 could be missed before is sees another. The s7 will receive every single notification as expected.
The background scan rate is set to scan for 1.1 secs and wait for 10 seconds. I wish I could provide logs for the issue but when the phone is plugged in the issue doesn't occur, so I can't really pin point why the s9 would be acting this way when the s7 doesn't. I assume it has to be something with doze mode or sleep mode since when the power cord is plugged in, the s9 receives all the notifications as expected. Those are the only two phones I have been able to test so I don't know if it is also an issue with the s8.
What could be causing the s9 to not range the same as the s7 when locked by the power button? If the phone just goes to sleep on its own, it acts the same as if the power button were pressed to put it to sleep. Code snippet below.
Thanks!
mBeaconManager = BeaconManager.getInstanceForApplication(this.getApplicationContext());
set_forground_notification(true);
logManager.setLogger(Loggers.verboseLogger());
logManager.setVerboseLoggingEnabled(true);
mBeaconManager.setAndroidLScanningDisabled(false); // Setting to false allows low latency scanning
mBeaconManager.setRegionStatePersistenceEnabled(false);
mBeaconManager.setBackgroundScanPeriod(1100);
mBeaconManager.setForegroundScanPeriod(1100);
mBeaconManager.setForegroundBetweenScanPeriod(2000);
mBeaconManager.setBackgroundBetweenScanPeriod(10000);
mBeaconManager.setBackgroundMode(true); // this is being set to true here so that on app termination
// or reboot when the app starts back up because of the service, the scanning period
// is set to background and not foreground
private void set_forground_notification(boolean post)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (post) {
String CHANNEL_ID = "Scanning_for_device";
CharSequence name = "Scanning_for_device";
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name, android.app.NotificationManager.IMPORTANCE_HIGH);
mChannel.setShowBadge(false);
mChannel.setSound(null,null);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_foreground_logo)
.setContentTitle("Scanning for Device")
.setSound(null)
.setOnlyAlertOnce(true);
Intent intent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(
this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(pendingIntent);
android.app.NotificationManager mNotificationManager =
(android.app.NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.createNotificationChannel(mChannel);
// sends foreground notification and starts foreground scanning?
mBeaconManager.enableForegroundServiceScanning(mBuilder.build(), 457);
} else {
// removes foreground notification and stops foreground scanning?
mBeaconManager.disableForegroundServiceScanning();
}
}
}

adsheet warning

can anyone explain the meaning/reason of this adsheet warning please?
Nov 23 09:24:06 unknown AdSheet[256] <Warning>: AdSheet running for 59.992 seconds with 1 clients and 1 assertions [banner:1]: info.company.app (State: Foreground Running) (Background: 0, no timer) has 1 banners: 0xee74b00:EDFD972C-2C31-45A6-A57C-F129F8D0CB97 (created 2011-11-23 17:23:44 +0000) [Visible: never] [In Window: YES]
it repeats every 20 seconds (in the log) and increments the "running for xx.xx seconds" with 20 seconds each time.
It comes up in the log with my iAd supported application and regardless whether the Test Advertisement is loaded or not.
after I kill the application it continues two or three times with:
Nov 23 09:33:06 unknown AdSheet[256] <Warning>: AdSheet running for 599.993 seconds with 0 clients and 0 assertions []:
and then it stops
thank you
I'm pretty sure the [Visible: never] has to do with the warning. Are you sure your AdSheet is visible and entirely on the screen? Did you by any chance accidently add a copy of the AdSheet to your viewController in IB that you don't know of? You should keep in mind that Ads should appear in the foreground.

Resources