AlamofireNetworkActivityIndicator not working - iphone

I have integrated Alamofire,SwiftyJson and AlamofireNetworkActivityIndicator frameworks via pod in my project. The AlamofireNetworkActivityIndicator is not showing up after following the instructions given in their Github page.
https://github.com/Alamofire/AlamofireNetworkActivityIndicator
It says all that is required for the activity indicator to work is the following line of code:
NetworkActivityIndicatorManager.shared.isEnabled = true
I basically just need a activity indicator to show whenever a request is being made or data is loading(Alamofire methods)

You have actually misunderstood AlamofireNetworkActivityIndicator is not actually a UIActivityIndicator like MBProgressHUD or SVProgressHUD. It will show a spinner in the status bar when an API call is there.
This will use to show NetworkActivityIndicatorManager.shared.isEnabled = true and false will hide from the status bar.
//Using MBProgressHUD
//Show indicator
MBProgressHUD.showHUDAddedTo(self.view, animated: true)
Alamofire.request(.POST, URL, parameters: parameter, encoding: .JSON)
.responseJSON { response in
//Hide indicator
MBProgressHUD.hideAllHUDsForView(self.view, animated: true)
}

As mentioned by Parth the NetworkActivityIndicatorManager of almofire is not actually a UIActivityIndicator. For Activity Indicator you could use many of the third party available for toast message and instead on installing the cocoapod for all the files try the files to add manually this will not increase the size of your app as the cocoapods does during installation
for Toast message you could use this : Toast message by Charles Scalesse
1). Download the file and add the toast.swift file in your project
2). to add toast you have to write self.maketoast

Related

Customize AWS Amplify authentication UI for iOS

I'm trying to customize the logo on the signIn page using the following:
AWSMobileClient.sharedInstance()
.showSignIn(navigationController: self.navigationController!,
signInUIOptions: SignInUIOptions(
canCancel: false,
logoImage: UIImage(named: "MyCustomLogo"),
backgroundColor: UIColor.black)) { (result,
err) in
//handle results and errors
}
However, the default logo still appears but the background does turn black. I have MyCustomLogo in the project but it just does not take. I'm fairly new to Apple development so I'm sure I'm missing something simple or maybe I'm not. I just need help pleaseĀ :)
I am able to add a custom logo to my Amplify Drop-In UI using the iOS SDK. You have to be sure to add your logo assets in the Assets.xcassets folder for your project to know where to look and override. Also, I presume you named your logo MyCustomLogo as you show in your code block above. You don't need to specify .png.

Running the google places modal popup in flutter

Looking at the flutter code it seems like I should be able to run the google places modal dialog since it does a full screen thing and doesn't try and overlay on top of flutter.
However I am having an issue where the modal shows up and then disappears again immediately. I am not entirely sure how to solve this...
I am activating it with:
call.method == "openPlacesDialogModal" -> {
val code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(activity)
if (GoogleApiAvailability.getInstance().showErrorDialogFragment(activity, code, REQUEST_GOOGLE_PLAY_SERVICES)) {
return
}
//val intent = Intent(activity, PlacesActivity::class.java)
//activity.startActivity(intent)
var intentBuilder = PlacePicker.IntentBuilder()
activity.startActivityForResult(intentBuilder.build(activity), PLACE_PICKER_REQUEST)
placeResult = result
return
}
In the logs I get:
I/FlutterActivityDelegate(18184): onResume setting current activity to this
I/flutter (18184): Opening picker
I/FlutterActivityDelegate(18184): onResume setting current activity to this
I think it is the onResume getting back to the ActivityDelegate that is the issue.
I put this on top of a completely different activity too, which kind of works. It shows the dialog for longer. I made sure I have all the right permissions, I have the fine location, internet permissions. Do I need to setup anything else?
Thanks,
David.
Error here was that I was not setting up the google api correctly and it was erroring immediately. Had to put in some checks to look for this error so I could respond correctly to the app that an error occurred.

print not working in Swift 3 extensions

I'm new at Swift 3 and I try to make a print("Test") in a Widget extension.
I tried the same code in ViewController.swift and It works ok. I don't know why it works there but it doesn't on TodayViewController.swift. I can't access to objects too.
func loadData() {
let query = PFQuery(className: "Noticias")
query.whereKey("titulo", equalTo:"Es Navidad")
query.findObjectsInBackground(block: { (objects : [PFObject]?, error: Error?) -> Void in
if error == nil {
// The find succeeded.
print("Successfully retrieved \(objects!.count) scores.")
// Do something with the found objects
if let objects = objects {
for object in objects {
print(object.objectId!)
}
}
} else {
// Log details of the failure
print("bad day homie")
print(error!)
}
})
}
I attach I picture to see it clearly. If I try to print on the file marked as Work, it works. But if I try it on the file marked ad NO, it doesn't.
It is extremely difficult to retrieve print messages from an extension. The problem is that it's an extension! It isn't running in your app, so it doesn't arrive at your console. Sometimes I find you can solve this problem by switching the debugged process in the Debug Bar at the top of the debug area (at the bottom of the screen, not shown in your screen shot), but at other times this doesn't work.
I'll illustrate a possible technique that seems to be pretty reliable. Look at this screen shot:
"Expand" is an action extension. But my containing app is called "bk2ch13...". So how will I ever manage to pause at the breakpoint shown at the right, which is in the action extension? This is what I do.
First, with the screen as shown above, I build and run my containing app.
Then, I switch the target to the action extension:
Now I build and run again. But now I am trying to run an action extension, which you can't do, so Xcode asks me what app to run:
So I choose "bk2ch13...". So now we are running my host app again, but we are debugging the extension. So I use my host app to exercise the extension, and sure enough, we pause at the breakpoints and print statements arrive into the console.
Note, in that screen shot, how the debug bar clearly shows that we are talking to the extension, not the host app.

how to add a custom entry in UIActivityViewController

When i open an attachment from iPhone or iPad mail application, there is a popup that can transfert the file to a third party application.
This iOS popup is called UIActivityViewController.
I wand to add my own iOS application (written in swift) in this popup and i do not know how to do...
Thanks
I believe you are asking about two separate things.
UIActivityViewController:
Here's my code in my app.
let vc = UIActivityViewController(activityItems: [shareImage], applicationActivities: [])
vc.excludedActivityTypes = [
UIActivityType.airDrop,
UIActivityType.assignToContact,
UIActivityType.addToReadingList,
//UIActivityType.copyToPasteboard,
//UIActivityType.mail,
//UIActivityType.message,
//UIActivityType.openInIBooks,
//UIActivityType.postToFacebook,
//UIActivityType.postToFlickr,
UIActivityType.postToTencentWeibo,
//UIActivityType.postToTwitter,
UIActivityType.postToVimeo,
UIActivityType.postToWeibo,
UIActivityType.print,
//UIActivityType.saveToCameraRoll
]
present(vc,
animated: true,
completion: nil)
vc.popoverPresentationController?.sourceView = self.view
vc.completionWithItemsHandler = {(activity, success, items, error) in
}
Pay attention to the excludedActiviyTypes code. My app is an image effect app, so I commented out the things I wish to have in the popup - Weibo, print, assignToContact, ReadingList, Vimeo, and TencentWeibo. Here's the thing - I kept the full list of activities for quick reference. (I've never found it on ADC and end up getting it by using code complete.)
UIActivityType is an extended struct, so if you want to go the route of using it this way I think you'll have to (1) subclass UIActivityViewController, (2) write your own extension to UIActivityType, and (3) provide any/all code needed to use a service that isn't listed above.
A Document Provider is what I think you are looking for. Either that, or Universal - sometimes called Deep - Linking. (The links are to Apple documentation for using each.)
I've obviously used UIActivityiewController, but haven't (yet) had any need to these other two.
If you have questions about setting up a UIActivityViewController, post them in the comments. If someone else has a way to "extend" it in any way other than I described, let me know and I'll remove this answer.

Take screenshot of host app using iOS share/action extensions?

I will like to know how to take a screenshot of the iOS host app with the use of a share/action extension.
My use case is as follows:
use the Safari browser to access a webpage (https such as gmail)
tap on the Share button and select the extension
the extension will take a screenshot of the current webpage
An working example for this use case is the Awesome Screenshot iOS app.
I had tried the following methods
reload the baseURI (loadRequest) on a UIWebView/WKWebkit (would not be able to access https contents such as Gmail). So not doing any reload (Awesome Screenshot is not doing a reload btw)
Used the ExtensionPreprocessingJS to obtain the DOM contents through the arguments.completionFunction function. I could not extract the document.body here although i could get the source etc. loadHTMLString with the baseURI will mess up the presentation layer.
Used html2canvas in the ExtensionPreprocessingJS to obtain an image and appended it to the host app's webpage as a child but do not know how to extract it. Also, the image got lost for some webpages such as Gmail.
Mobile Safari does not have the visibleContentsAsDataURL method.
I think a viable approach will be to use the html2canvas in the ExtensionPreprocessingJS but how do I save this image somehow?
Edit: So the below works in the Simulator but does not work on the device. I'm presently looking for a solution as well.
Here's a solution that I think the Awesome Screenshot app uses:
func captureScreen() -> UIImage
{
// Get the "screenshot" view.
let view = UIScreen.mainScreen().snapshotViewAfterScreenUpdates(false)
// Add the screenshot view as a subview of the ShareViewController's view.
self.view.addSubview(view);
// Now screenshot *this* view.
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, false, 0);
self.view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true)
let image: UIImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// Finally, remove the subview.
view.removeFromSuperview()
return image
}