Voting: 
Vote up!
0 Votes
0 Replies
New

iOS Today Widget: Issues Using iOS Native Function APIs

Question asked by Zach Sabin on Aug 10, 2017 15:19 EDT

I am having trouble working with the iOS Native Function APIs for app extensions. I am having the following issues.  I cannot find a way to perform a POST request using these APIs. I am trying to convert the following Objective-C code to JavaScript: NSString postData = "data to post"; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; ... [request setHTTPBody: postData] NSMutableURLRequest, however, takes an NSData object for its HTTPBody property. But I can't figure out a way to create an NSData object from my string containing my POST data, since NSString objects are automatically converted to JavaScript strings. I also cannot get the NSLog function to work and can't find another way to perform any logging. Are there any work arounds for these issues? Thank you!