Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Natenezz

macrumors newbie
Original poster
Apr 14, 2017
4
0
Please help!

My goal: Create a Cocoa Touch Framework that is a syncing framework for different Cloud API Storage Services (Azure, AWS, Filemaker API*)



Currently, I use FileMaker Pro with FileMaker Go IOS APP SDK the most. FileMaker Inc. has created a Cocoa Touch Framework bundle that is basically an entire application within it, I assume the AppDelegate and ViewController classes are within it, but I can't tell because they are compiled.



I would like to create a second Framework with Coca Touch that can run background tasks / downloads triggered by my custom framework.

I have been sucessfull at embedding my framework along side FileMaker Go's iOS App SDK and running commands, I can push JSON, get JSON, and download files but only in the main thread, once the app goes to sleep the download triggered from my framework stops. I am using NSURLSession to do all of this. But as soon as I try to attach a NSURLSession Background Config everything stops working and fails.



I do not have direct access to the App's AppDelegate or ViewController Classes. I cannot modify them direclty.



NSURLSessionConfiguration *backgroundConfiguration = [NSURLSessionConfiguration backgroundSessionConfiguration:mad:"com.captech.NSURLSample.BackgroundSession"]; NSURLSession *backgroundSession = [NSURLSession sessionWithConfiguration:backgroundConfiguration delegate:self delegateQueue:nil];



- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite { if (downloadTask == self.downloadTask && self.progressAction){ self.progressAction((double)totalBytesWritten, (double)totalBytesExpectedToWrite); } }


My problem lies I think in the delegate:self identifier. This never resolves. I have tried removing it but nothing downloads. I have tried a PCH prefix header to identiy the appdelegate but not luck. I also trid the (MyAppdD *) UIApp SharedApp delegate to try to get a reference but since the Framework I'm building isnt embeded in the app yet I don't think it can resolve.

But if I can figure out how to reference the appdelegate or get around attaching new tasks to it so that I can run background downloads from my Cocoa Touch Framework that would be awesome.

Good Resources on NSURLSession Usage that I tried, but not luck with the delegate:self on the background stuff. If I don't need the background execution then everything works fine becuase I don't have to define delegate:self ever.

http://hayageek.com/ios-nsurlsession-example/#background-download

https://www.captechconsulting.com/blogs/ios-7-tutorial-series--nsurlsession

https://developer.apple.com/library.../BackgroundExecution/BackgroundExecution.html

https://code.tutsplus.com/tutorials/networking-with-nsurlsession-part-1--mobile-21394

http://corsarus.com/2015/background-fetching-using-nsurlsession/

https://www.infragistics.com/commun...ve-c-downloading-data-using-nsurlsession.aspx



Any thoughts or suggestions on this Framework to Framework communication for the AppDelegate Self and Viewcontroller would be awesome.

Please remember my coca touch framework that I am building must be able to compile before being added to the FileMaker SKD iOS APP Project.



Thanks,



Nate
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
A few random comments:

background downloads are somewhat complicated. If I were you I would build a separate app and get background downloads working there before attempting to integrate it into this app you're building.

Look up the objective-c classdump tool. It will help you find the names of the classes in the SDK. Also, man nm.

You can access the app delegate directly from UIApplication. You can probably also set your own app delegate even though the SDK sets its own. If you did that you could call through to the SDK app delegate from your delegate methods and it should still work. There might be other trickery that you could do to add your own callbacks for the background downloads.
 

Natenezz

macrumors newbie
Original poster
Apr 14, 2017
4
0
Code:
@optional
@property(readonly, copy) NSString *debugDescription;
@end

@protocol NSURLSessionDataDelegate <NSURLSessionTaskDelegate>

@optional
- (void)URLSession:(NSURLSession *)arg1 dataTask:(NSURLSessionDataTask *)arg2 willCacheResponse:(NSCachedURLResponse *)arg3 completionHandler:(void (^)(NSCachedURLResponse *))arg4;
- (void)URLSession:(NSURLSession *)arg1 dataTask:(NSURLSessionDataTask *)arg2 didReceiveData:(NSData *)arg3;
- (void)URLSession:(NSURLSession *)arg1 dataTask:(NSURLSessionDataTask *)arg2 didBecomeStreamTask:(NSURLSessionStreamTask *)arg3;
- (void)URLSession:(NSURLSession *)arg1 dataTask:(NSURLSessionDataTask *)arg2 didBecomeDownloadTask:(NSURLSessionDownloadTask *)arg3;
- (void)URLSession:(NSURLSession *)arg1 dataTask:(NSURLSessionDataTask *)arg2 didReceiveResponse:(NSURLResponse *)arg3 completionHandler:(void (^)(long long))arg4;
@end

@protocol NSURLSessionDelegate <NSObject>

@optional
- (void)URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession *)arg1;
- (void)URLSession:(NSURLSession *)arg1 didReceiveChallenge:(NSURLAuthenticationChallenge *)arg2 completionHandler:(void (^)(long long, NSURLCredential *))arg3;
- (void)URLSession:(NSURLSession *)arg1 didBecomeInvalidWithError:(NSError *)arg2;
@end

@protocol NSURLSessionTaskDelegate <NSURLSessionDelegate>

@optional
- (void)URLSession:(NSURLSession *)arg1 task:(NSURLSessionTask *)arg2 didCompleteWithError:(NSError *)arg3;
- (void)URLSession:(NSURLSession *)arg1 task:(NSURLSessionTask *)arg2 didSendBodyData:(long long)arg3 totalBytesSent:(long long)arg4 totalBytesExpectedToSend:(long long)arg5;
- (void)URLSession:(NSURLSession *)arg1 task:(NSURLSessionTask *)arg2 needNewBodyStream:(void (^)(NSInputStream *))arg3;
- (void)URLSession:(NSURLSession *)arg1 task:(NSURLSessionTask *)arg2 didReceiveChallenge:(NSURLAuthenticationChallenge *)arg3 completionHandler:(void (^)(long long, NSURLCredential *))arg4;
- (void)URLSession:(NSURLSession *)arg1 task:(NSURLSessionTask *)arg2 willPerformHTTPRedirection:(NSHTTPURLResponse *)arg3 newRequest:(NSURLRequest *)arg4 completionHandler:(void (^)(NSURLRequest *))arg5;
@end

@protocol ObscuredTextViewDelegate <UITextFieldDelegate>
- (void)textFieldDidChange:(ObscuredTextView *)arg1;
- (void)textFieldDidChangeSelection:(ObscuredTextView *)arg1 toRange:(struct _NSRange)arg2;
@end
[doublepost=1492218158][/doublepost]This Top Code Block is the Classes in the FrameWork App that I cannot edit directly for the NSURL Delegate
[doublepost=1492218248][/doublepost]This bottom block of code if from the same SDK Framework but shows UIAppDelegate classes
 
Last edited:

Natenezz

macrumors newbie
Original poster
Apr 14, 2017
4
0
Code:
@protocol UIApplicationDelegate <NSObject>

@optional
@property(retain, nonatomic) UIWindow *window;
- (void)application:(UIApplication *)arg1 didUpdateUserActivity:(NSUserActivity *)arg2;
- (void)application:(UIApplication *)arg1 didFailToContinueUserActivityWithType:(NSString *)arg2 error:(NSError *)arg3;
- (_Bool)application:(UIApplication *)arg1 continueUserActivity:(NSUserActivity *)arg2 restorationHandler:(void (^)(NSArray *))arg3;
- (_Bool)application:(UIApplication *)arg1 willContinueUserActivityWithType:(NSString *)arg2;
- (void)application:(UIApplication *)arg1 didDecodeRestorableStateWithCoder:(NSCoder *)arg2;
- (void)application:(UIApplication *)arg1 willEncodeRestorableStateWithCoder:(NSCoder *)arg2;
- (_Bool)application:(UIApplication *)arg1 shouldRestoreApplicationState:(NSCoder *)arg2;
- (_Bool)application:(UIApplication *)arg1 shouldSaveApplicationState:(NSCoder *)arg2;
- (UIViewController *)application:(UIApplication *)arg1 viewControllerWithRestorationIdentifierPath:(NSArray *)arg2 coder:(NSCoder *)arg3;
- (_Bool)application:(UIApplication *)arg1 shouldAllowExtensionPointIdentifier:(NSString *)arg2;
- (unsigned long long)application:(UIApplication *)arg1 supportedInterfaceOrientationsForWindow:(UIWindow *)arg2;
- (void)applicationProtectedDataDidBecomeAvailable:(UIApplication *)arg1;
- (void)applicationProtectedDataWillBecomeUnavailable:(UIApplication *)arg1;
- (void)applicationWillEnterForeground:(UIApplication *)arg1;
- (void)applicationDidEnterBackground:(UIApplication *)arg1;
- (void)applicationShouldRequestHealthAuthorization:(UIApplication *)arg1;
- (void)application:(UIApplication *)arg1 handleWatchKitExtensionRequest:(NSDictionary *)arg2 reply:(void (^)(NSDictionary *))arg3;
- (void)application:(UIApplication *)arg1 handleEventsForBackgroundURLSession:(NSString *)arg2 completionHandler:(void (^)(void))arg3;
- (void)application:(UIApplication *)arg1 performActionForShortcutItem:(UIApplicationShortcutItem *)arg2 completionHandler:(void (^)(_Bool))arg3;
- (void)application:(UIApplication *)arg1 performFetchWithCompletionHandler:(void (^)(unsigned long long))arg2;
- (void)application:(UIApplication *)arg1 didReceiveRemoteNotification:(NSDictionary *)arg2 fetchCompletionHandler:(void (^)(unsigned long long))arg3;
- (void)application:(UIApplication *)arg1 handleActionWithIdentifier:(NSString *)arg2 forLocalNotification:(UILocalNotification *)arg3 withResponseInfo:(NSDictionary *)arg4 completionHandler:(void (^)(void))arg5;
- (void)application:(UIApplication *)arg1 handleActionWithIdentifier:(NSString *)arg2 forRemoteNotification:(NSDictionary *)arg3 completionHandler:(void (^)(void))arg4;
- (void)application:(UIApplication *)arg1 handleActionWithIdentifier:(NSString *)arg2 forRemoteNotification:(NSDictionary *)arg3 withResponseInfo:(NSDictionary *)arg4 completionHandler:(void (^)(void))arg5;
- (void)application:(UIApplication *)arg1 handleActionWithIdentifier:(NSString *)arg2 forLocalNotification:(UILocalNotification *)arg3 completionHandler:(void (^)(void))arg4;
- (void)application:(UIApplication *)arg1 didReceiveLocalNotification:(UILocalNotification *)arg2;
- (void)application:(UIApplication *)arg1 didReceiveRemoteNotification:(NSDictionary *)arg2;
- (void)application:(UIApplication *)arg1 didFailToRegisterForRemoteNotificationsWithError:(NSError *)arg2;
- (void)application:(UIApplication *)arg1 didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)arg2;
- (void)application:(UIApplication *)arg1 didRegisterUserNotificationSettings:(UIUserNotificationSettings *)arg2;
- (void)application:(UIApplication *)arg1 didChangeStatusBarFrame:(struct CGRect)arg2;
- (void)application:(UIApplication *)arg1 willChangeStatusBarFrame:(struct CGRect)arg2;
- (void)application:(UIApplication *)arg1 didChangeStatusBarOrientation:(long long)arg2;
- (void)application:(UIApplication *)arg1 willChangeStatusBarOrientation:(long long)arg2 duration:(double)arg3;
- (void)applicationSignificantTimeChange:(UIApplication *)arg1;
- (void)applicationWillTerminate:(UIApplication *)arg1;
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)arg1;
- (_Bool)application:(UIApplication *)arg1 openURL:(NSURL *)arg2 options:(NSDictionary *)arg3;
- (_Bool)application:(UIApplication *)arg1 openURL:(NSURL *)arg2 sourceApplication:(NSString *)arg3 annotation:(id)arg4;
- (_Bool)application:(UIApplication *)arg1 handleOpenURL:(NSURL *)arg2;
- (void)applicationWillResignActive:(UIApplication *)arg1;
- (void)applicationDidBecomeActive:(UIApplication *)arg1;
- (_Bool)application:(UIApplication *)arg1 didFinishLaunchingWithOptions:(NSDictionary *)arg2;
- (_Bool)application:(UIApplication *)arg1 willFinishLaunchingWithOptions:(NSDictionary *)arg2;
- (void)applicationDidFinishLaunching:(UIApplication *)arg1;
@end
 

Natenezz

macrumors newbie
Original poster
Apr 14, 2017
4
0
I have an example app running well with background downloads and moved all the files into my framework but nothing happens. I pretty sure we can only use one AppDelegate Class per Xcode Project.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.