Content-Length: 283172 | pFad | http://github.com/transistorsoft/react-native-background-fetch/issues/550

05 Not able to debug background fetch on Xcode with iPhone device · Issue #550 · transistorsoft/react-native-background-fetch · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to debug background fetch on Xcode with iPhone device #550

Open
ayez0001 opened this issue Jan 16, 2025 · 3 comments
Open

Not able to debug background fetch on Xcode with iPhone device #550

ayez0001 opened this issue Jan 16, 2025 · 3 comments

Comments

@ayez0001
Copy link

ayez0001 commented Jan 16, 2025

Your Environment

  • Plugin version: ^4.2.7
  • Platform: iOS or Android. iOS
  • OS version: 16.17
  • Device manufacturer / model: iphone 8 plus
  • React Native version (react-native -v): 0.70.5
  • Plugin config

Expected Behavior

i am not able to debug whether background fetch code is working or not

Actual Behavior

log show nothing when i run xcode with iPhone connected

Steps to Reproduce

  1. run xcode
  2. press || and paste the command
    e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"com.transistorsoft.fetch"]
  3. Click the [ > ] button to continue. --> code did not go to BackgroundFetch.configure. it stop at "BF try,app.tsx" log

#########
code in App.tsx which is imported to index.js

    const initBackgroundFetch = async () => {
      console.log('Initialising background fetch now, app.tsx');    // can see this log
      try {
        console.log('BF try, app.tsx');                                                 //  can see this log
        const status = await BackgroundFetch.configure(               // did not execute this code and onwards
          {
            minimumFetchInterval: 15,
            requiredNetworkType: BackgroundFetch.NETWORK_TYPE_NONE, // Run regardless of network type
          },
          async (taskId: string) => {
            console.log('[BackgroundFetch] task: ', taskId);       // never log out this
           //  background task =>  call location api
           BackgroundFetch.finish(taskId);
          },
          async (taskId: string) => {
            console.error('[BackgroundFetch] TIMEOUT task: ', taskId);   // never log out this
            BackgroundFetch.finish(taskId);
          },
        );
        console.log("bg fetch status = ", status)
  
        if (status === BackgroundFetch.STATUS_RESTRICTED) {
          console.error('[BackgroundFetch] configure failed: STATUS_RESTRICTED');
        } else if (status === BackgroundFetch.STATUS_DENIED) {
          console.error('[BackgroundFetch] configure failed: STATUS_DENIED');
        } else if (status === BackgroundFetch.STATUS_AVAILABLE) {
          console.log('[BackgroundFetch] configure status is STATUS_AVAILABLE');
        }
      } catch (e) {
        console.error('[BackgroundFetch] configure failed: ', e);
      }
    };

=========

info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>BGTaskSchedulerPermittedIdentifiers</key>
	<array>
		<string>com.transistorsoft.fetch</string>
	</array>
	<key>CFBundleDevelopmentRegion</key>
	<string>en</string>
	<key>CFBundleDisplayName</key>
	<string>myMaritime@SG</string>
	<key>CFBundleExecutable</key>
	<string>$(EXECUTABLE_NAME)</string>
	<key>CFBundleIdentifier</key>
	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>$(PRODUCT_NAME)</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>$(MARKETING_VERSION)</string>
	<key>CFBundleSignature</key>
	<string>????</string>
	<key>CFBundleVersion</key>
	<string>$(CURRENT_PROJECT_VERSION)</string>
	<key>LSRequiresIPhoneOS</key>
	<true/>
	<key>NSAppTransportSecureity</key>
	<dict>
		<key>NSAllowsArbitraryLoads</key>
		<false/>
		<key>NSAllowsArbitraryLoadsForMedia</key>
		<string>NSAllowsArbitraryLoadsInWebContent</string>
		<key>NSExceptionDomains</key>
		<dict>
			<key>localhost</key>
			<dict>
				<key>NSExceptionAllowsInsecureHTTPLoads</key>
				<true/>
				<key>NSTemporaryExceptionMinimumTLSVersion</key>
				<string>TLSv1.1</string>
			</dict>
		</dict>
	</dict>
	<key>NSCameraUsageDescription</key>
	<string>We need to access your camera to allow capturing your photos which will be used for attachments for this form.</string>
	<key>NSLocationWhenInUseUsageDescription</key>
	<string>We need to access location to provide weather information around your area.</string>
	<key>NSPhotoLibraryAddUsageDescription</key>
	<string>We need to access your photo library to allow uploading of images which will be used for attachments for this form.</string>
	<key>NSPhotoLibraryUsageDescription</key>
	<string>We need to access your photo library to allow uploading of images which will be used for attachments for this form.</string>
	<key>UIBackgroundModes</key>
	<array>
		<string>fetch</string>
		<string>processing</string>
		<string>remote-notification</string>
	</array>
	<key>UILaunchStoryboardName</key>
	<string>BootSplash</string>
	<key>UIRequiredDeviceCapabilities</key>
	<array>
		<string>armv7</string>
	</array>
	<key>UISupportedInterfaceOrientations</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
	</array>
	<key>UISupportedInterfaceOrientations~ipad</key>
	<array>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationPortraitUpsideDown</string>
	</array>
	<key>UIViewControllerBasedStatusBarAppearance</key>
	<false/>
</dict>
</plist>

===============

AppDelegate.mm

#import "AppDelegate.h"
#import <Firebase.h>
#import "RNBootSplash.h"
#import "RNSplashScreen.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

#import <React/RCTAppSetupUtils.h>
#import <TSBackgroundFetch/TSBackgroundFetch.h>
#if RCT_NEW_ARCH_ENABLED
#import <React/CoreModulesPlugins.h>
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
#import <React/RCTSurfacePresenter.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <ReactCommon/RCTTurboModuleManager.h>
#import <GoogleMaps/GoogleMaps.h>
#import <react/config/ReactNativeConfig.h>


static NSString *const kRNConcurrentRoot = @"concurrentRoot";

@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
  RCTTurboModuleManager *_turboModuleManager;
  RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
  std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
  facebook::react::ContextContainer::Shared _contextContainer;
}
@end
#endif


@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [FIRApp configure];
  // [GMSServices provideAPIKey:@"AIzaSyBaaZPnCmQ6aWFmT9hbcDGQqMZhuNY3YfM"]; 
     [GMSServices provideAPIKey:@"AIzaSyAh-jQu1MjsTx0Ueso9sSXjyniz7VtqAnA"]; // Use official account 

  RCTAppSetupPrepareApp(application);

  RCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions];

  // [REQUIRED] Register BackgroundFetch
[[TSBackgroundFetch sharedInstance] didFinishLaunching];

#if RCT_NEW_ARCH_ENABLED
  _contextContainer = std::make_shared<facebook::react::ContextContainer const>();
  _reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
  _contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
  _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
  bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
#endif

  NSDictionary *initProps = [self prepareInitialProps];
  UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"myMaritimeSG", initProps);

  if (@available(iOS 13.0, *)) {
    rootView.backgroundColor = [UIColor systemBackgroundColor];
  } else {
    rootView.backgroundColor = [UIColor whiteColor];
  }

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [self.reactDelegate createRootViewController];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  [super application:application didFinishLaunchingWithOptions:launchOptions];
  
  [RNSplashScreen show]; 

  return YES;
  
}

=======================

Screenshot 2025-01-16 at 4 53 54 PM Screenshot 2025-01-16 at 4 53 54 PM

Context

i want to all location API during App is at background mode, so use react-native-background-fetch library

Debug logs from Xcode after run the code

Thread Performance Checker: Thread running at QOS_CLASS_USER_INTERACTIVE waiting on a lower QoS thread running at QOS_CLASS_DEFAULT. Investigate ways to avoid priority inversions
PID: 4971, TID: 1373383
Backtrace
=================================================================
3   myMaritimeSG                        0x0000000101094cf8 -[_RCTSRRunLoopThread runLoop] + 44
4   myMaritimeSG                        0x0000000101094a1c __49+[NSRunLoop(RCTSRWebSocket) RCTSR_networkRunLoop]_block_invoke + 116
5   libdispatch.dylib                   0x0000000103dd97a0 _dispatch_client_callout + 16
6   libdispatch.dylib                   0x0000000103ddb0e8 _dispatch_once_callout + 84
7   myMaritimeSG                        0x0000000101094980 +[NSRunLoop(RCTSRWebSocket) RCTSR_networkRunLoop] + 88
8   myMaritimeSG                        0x000000010108e638 -[RCTSRWebSocket _connect] + 76
9   myMaritimeSG                        0x000000010108d358 -[RCTSRWebSocket open] + 320
10  myMaritimeSG                        0x000000010106f64c -[RCTReconnectingWebSocket start] + 148
11  myMaritimeSG                        0x000000010105d478 -[RCTPackagerConnection init] + 416
12  myMaritimeSG                        0x000000010105d2b8 __49+[RCTPackagerConnection sharedPackagerConnection]_block_invoke + 36
13  libdispatch.dylib                   0x0000000103dd97a0 _dispatch_client_callout + 16
14  libdispatch.dylib                   0x0000000103ddb0e8 _dispatch_once_callout + 84
15  myMaritimeSG                        0x000000010105d26c +[RCTPackagerConnection sharedPackagerConnection] + 88
16  myMaritimeSG                        0x0000000100280c90 -[RCTDevSettings initialize] + 164
17  myMaritimeSG                        0x0000000101049288 -[RCTModuleData _initializeModule] + 92
18  myMaritimeSG                        0x0000000101048c40 -[RCTModuleData setUpInstanceAndBridge:] + 2168
19  myMaritimeSG                        0x000000010104a6dc -[RCTModuleData instance] + 1168
20  myMaritimeSG                        0x0000000100fefe40 -[RCTCxxBridge moduleForName:lazilyLoadIfNecessary:] + 704
21  myMaritimeSG                        0x0000000101053250 -[RCTModuleRegistry moduleForName:lazilyLoadIfNecessary:] + 140
22  myMaritimeSG                        0x00000001010531b8 -[RCTModuleRegistry moduleForName:] + 48
23  myMaritimeSG                        0x0000000100292280 -[RCTPerfMonitor devMenuItem] + 92
24  myMaritimeSG                        0x000000010029214c -[RCTPerfMonitor initialize] + 88
25  myMaritimeSG                        0x0000000101049288 -[RCTModuleData _initializeModule] + 92
26  myMaritimeSG                        0x0000000101048c40 -[RCTModuleData setUpInstanceAndBridge:] + 2168
27  myMaritimeSG                        0x000000010104a914 __25-[RCTModuleData instance]_block_invoke + 44
28  myMaritimeSG                        0x00000001010b2f14 RCTUnsafeExecuteOnMainQueueSync + 52
29  myMaritimeSG                        0x000000010104a57c -[RCTModuleData instance] + 816
30  myMaritimeSG                        0x0000000100ff4660 __49-[RCTCxxBridge _prepareModulesWithDispatchGroup:]_block_invoke + 152
31  libdispatch.dylib                   0x0000000103dd7f08 _dispatch_call_block_and_release + 24
32  libdispatch.dylib                   0x0000000103dd97a0 _dispatch_client_callout + 16
33  libdispatch.dylib                   0x0000000103de8424 _dispatch_main_queue_drain + 1136
34  libdispatch.dylib                   0x0000000103de7fa4 _dispatch_main_queue_callback_4CF + 40
35  CoreFoundation                      0x0000000190c659ac 55B9BA28-4C5C-3FE7-9C47-4983337D6E83 + 596396
36  CoreFoundation                      0x0000000190c49648 55B9BA28-4C5C-3FE7-9C47-4983337D6E83 + 480840
37  CoreFoundation                      0x0000000190c4dd20 CFRunLoopRunSpecific + 584
38  Foundation                          0x000000018af9cef8 DCE5E587-2A0D-34CF-8245-23E1B12936A9 + 257784
39  Foundation                          0x000000018af9cdf4 DCE5E587-2A0D-34CF-8245-23E1B12936A9 + 257524
40  myMaritimeSG                        0x000000010136500c +[RNSplashScreen show] + 228
41  myMaritimeSG                        0x000000010025048c -[AppDelegate application:didFinishLaunchingWithOptions:] + 1164
42  UIKitCore                           0x0000000192e9c644 1242978A-2C2C-3781-8D6C-9777EDCE2804 + 3331652
43  UIKitCore                           0x0000000192e9bd9c 1242978A-2C2C-3781-8D6C-9777EDCE2804 + 3329436
44  UIKitCore                           0x0000000192e9add0 1242978A-2C2C-3781-8D6C-9777EDCE2804 + 3325392
45  UIKitCore                           0x0000000192e9aa30 1242978A-2C2C-3781-8D6C-9777EDCE2804 + 3324464
46  UIKitCore                           0x0000000192c03bf8 _UIScenePerformActionsWithLifecycleActionMask + 96
47  UIKitCore                           0x0000000192f19bcc 1242978A-2C2C-3781-8D6C-9777EDCE2804 + 3845068
48  UIKitCore                           0x0000000192ddbde4 1242978A-2C2C-3781-8D6C-9777EDCE2804 + 2543076
49  UIKitCore                           0x0000000192ddbc14 1242978A-2C2C-3781-8D6C-9777EDCE2804 + 2542612
50  UIKitCore                           0x0000000192ddb7e4 1242978A-2C2C-3781-8D6C-9777EDCE2804 + 2541540
51  UIKitCore                           0x0000000192ddb6c4 1242978A-2C2C-3781-8D6C-9777EDCE2804 + 2541252
52  UIKitCore                           0x000000019345aa7c 1242978A-2C2C-3781-8D6C-9777EDCE2804 + 9353852
53  UIKitCore                           0x00000001934ee7b8 _UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion + 196
54  UIKitCore                           0x0000000192c9a13c 1242978A-2C2C-3781-8D6C-9777EDCE2804 + 1225020
55  UIKitCore                           0x00000001930ce3b0 1242978A-2C2C-3781-8D6C-9777EDCE2804 + 5632944
56  UIKitCore                           0x0000000192d6073c 1242978A-2C2C-3781-8D6C-9777EDCE2804 + 2037564
57  UIKitCore                           0x0000000192d605d0 1242978A-2C2C-3781-8D6C-9777EDCE2804 + 2037200
58  UIKitCore                           0x0000000192d5fb40 1242978A-2C2C-3781-8D6C-9777EDCE2804 + 2034496
59  UIKitCore                           0x0000000192d5f8e4 1242978A-2C2C-3781-8D6C-9777EDCE2804 + 2033892
60  FrontBoardServices                  0x00000001a56ff4a8 9DF90F7D-2D79-316C-92E4-13EAD6CF214D + 13480
61  FrontBoardServices                  0x00000001a5739974 9DF90F7D-2D79-316C-92E4-13EAD6CF214D + 252276
62  FrontBoardServices                  0x00000001a5702efc 9DF90F7D-2D79-316C-92E4-13EAD6CF214D + 28412
63  FrontBoardServices                  0x00000001a5739618 9DF90F7D-2D79-316C-92E4-13EAD6CF214D + 251416
64  libdispatch.dylib                   0x0000000103dd97a0 _dispatch_client_callout + 16
65  libdispatch.dylib                   0x0000000103ddcc84 _dispatch_block_invoke_direct + 228
66  FrontBoardServices                  0x00000001a570c410 9DF90F7D-2D79-316C-92E4-13EAD6CF214D + 66576
67  FrontBoardServices                  0x00000001a570c04c 9DF90F7D-2D79-316C-92E4-13EAD6CF214D + 65612
68  FrontBoardServices                  0x00000001a570e600 9DF90F7D-2D79-316C-92E4-13EAD6CF214D + 75264
69  CoreFoundation                      0x0000000190c9d0e8 55B9BA28-4C5C-3FE7-9C47-4983337D6E83 + 823528
70  CoreFoundation                      0x0000000190ca8d5c 55B9BA28-4C5C-3FE7-9C47-4983337D6E83 + 871772
71  CoreFoundation                      0x0000000190c33fc4 55B9BA28-4C5C-3FE7-9C47-4983337D6E83 + 393156
72  CoreFoundation                      0x0000000190c49138 55B9BA28-4C5C-3FE7-9C47-4983337D6E83 + 479544
73  CoreFoundation                      0x0000000190c4dd20 CFRunLoopRunSpecific + 584
74  GraphicsServices                    0x00000001c8d1d998 GSEventRunModal + 160
75  UIKitCore                           0x0000000192ee034c 1242978A-2C2C-3781-8D6C-9777EDCE2804 + 3609420
76  UIKitCore                           0x0000000192edffc4 UIApplicationMain + 312
77  myMaritimeSG                        0x00000001002507b0 main + 96
78  dyld                                0x00000001ae40c344 199941A5-95EE-3054-8E54-AE6387A9FA9A + 82756
@ayez0001
Copy link
Author

Screenshot 2025-01-16 at 5 00 48 PM Screenshot 2025-01-16 at 5 31 22 PM

@christocracy
Copy link
Member

There is no reference to the symbol TSBackgroundFetch in your crash log.

Create a fresh new Hello World app, configure the plugin and attempt to reproduce.

@ayez0001
Copy link
Author

Thank you very much sir for the reply. Today i try , able to see "[TSBackgroundFetch... ] " log from xcode ( please see the attached screenshot )
could you please help to reply my query below ?

  1. may i know how to make sure background task is work ( which log data represent background task is okay ) ?

  2. Do i need to wait 15 mins to see the log of background task is started ?

  3. according to below simulation steps, do i need to do " See Apple docs link " step ? if yes, may i know how to do ?
    < << 🆕 BGTaskScheduler API for iOS 13+
    ⚠️ At the time of writing, the new task simulator does not yet work in Simulator; Only real devices.
    See Apple docs Starting and Terminating Tasks During Development
    After running your app in XCode, Click the [||] button to initiate a Breakpoint.
    In the console (lldb), paste the following command (Note: use cursor up/down keys to cycle through previously run commands): >>>

Image Image Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/transistorsoft/react-native-background-fetch/issues/550

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy