iOS位置更新甚至应用程序都没有运行(比如找我的iphone)

iOS位置更新甚至应用程序都没有运行(比如找我的iphone),第1张

概述我想编写位置跟踪应用程序,如“查找我的iPhone”,它运行在前台,后台,甚至终止(不运行).位置将定期发送到我的服务器.我在谷歌搜索并阅读了许多文档,教程评论,有关此主题的代码.然后我找到了 this tutorial.但在本教程中,位置被发送到前景中的“.txt”文件并且后台没有终止…我的意思是,当应用程序被杀死时,它不会在后台重新启动以发送位置“. txt“文件..所以我添加并更新了一些代码 我想编写位置跟踪应用程序,如“查找我的iPhone”,它运行在前台,后台,甚至终止(不运行).位置将定期发送到我的服务器.我在谷歌搜索并阅读了许多文档,教程评论,有关此主题的代码.然后我找到了 this tutorial.但在本教程中,位置被发送到前景中的“.txt”文件并且后台没有终止…我的意思是,当应用程序被杀死时,它不会在后台重新启动以发送位置“. txt“文件..所以我添加并更新了一些代码,以便在它不运行时发送位置..但是,我没有这样做…我的意思是,当我在多任务中杀死(关闭)应用程序时(双击)主页按钮),它不发送到位置…

你能帮助我吗,我该如何解决这个问题?

提前致谢

- (voID)locationManager:(CLLocationManager *)manager    dIDUpdatetoLocation:(CLLocation *)newLocation           fromLocation:(CLLocation *)oldLocation{    [self log:[Nsstring stringWithFormat:@"Background location %.06f %.06f %@",newLocation.coordinate.latitude,newLocation.coordinate.longitude,newLocation.timestamp]];}- (BOol)application:(UIApplication *)application dIDFinishLaunchingWithOptions:(NSDictionary *)launchOptions {        ID locationValue = [launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey];    if (locationValue)    {        // create a new manager and start checking for sig changes        [self log:@"dIDFinishLaunchingWithOptions location key"];        m_locManager = [[CLLocationManager alloc] init];        [self log:@"dIDFinishLaunchingWithOptions created manager"];        m_locManager.delegate = self;        [self log:@"dIDFinishLaunchingWithOptions set delegate"];        [m_locManager startMonitoringSignificantLocationChanges];        [self log:@"dIDFinishLaunchingWithOptions monitoring sig changes"];        return YES;    }    [self log:@"dIDFinishLaunchingWithOptions"];        return YES;}- (voID)applicationWillResignActive:(UIApplication *)application {    [self log:@"applicationWillResignActive"];    NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults];    [userDefaults setBool:vIEwController.m_significantSwitch.on forKey:@"significant"];    [userDefaults synchronize];}                - (voID)applicationDIDEnterBackground:(UIApplication *)application {    [self log:@"applicationDIDEnterBackground"];    [m_locManager startMonitoringSignificantLocationChanges];}- (voID)applicationWillEnterForeground:(UIApplication *)application {    [self log:@"applicationWillEnterForeground"];    [m_locManager stopMonitoringSignificantLocationChanges];}- (voID)applicationDIDBecomeActive:(UIApplication *)application {    [self log:@"applicationDIDBecomeActive"];    if (![window.subvIEws count])    {        // Add the vIEw controller's vIEw to the window and display.        [window addSubvIEw:vIEwController.vIEw];        [window makeKeyAndVisible];        NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults];        vIEwController.m_significantSwitch.on = [userDefaults boolForKey:@"significant"];        if (vIEwController.m_significantSwitch.on)            [vIEwController actionSignificant:nil];    }}- (voID)applicationWillTerminate:(UIApplication *)application {    [self log:@"applicationWillTerminate"];    [m_locManager startMonitoringSignificantLocationChanges];}
解决方法 我的朋友,你走错了路.实际上,在iOS中杀死应用程序后,没有任何方法可以执行任务.你可以阅读这个 here in Apple documentation.

查找我的iPhone – 这是一个Apple应用程序,他们使用私有API来实现这一目标.这些类型的功能不适用于通用开发人员编程.

所以请不要走这条路.所有人都将徒劳无功.

希望这有助于你!

总结

以上是内存溢出为你收集整理的iOS位置更新甚至应用程序都没有运行(比如找我的iphone)全部内容,希望文章能够帮你解决iOS位置更新甚至应用程序都没有运行(比如找我的iphone)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1007056.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存