ALAssetsLibraryChangedNotification is not work in ios5.0 - assetslibrary

The ALAssetsLibraryChangedNotification is not working in IOS 5.0. It works fine in the older IOS 4 version. How can I get it to wrok in IOS 5.0?

It is an ios5.0 Bug.
you can do one of the following:
1.) Call [self.assetsLibrary writeImageToSavedPhotosAlbum:nil metadata:nil completionBlock:^(NSURL *assetURL, NSError *error) { }]; immediately after creating instance of ALAssetsLibrary
2.) Observe ALAssetsLibraryChangedNotification (not NSManagedObjectContextObjectsDidChangeNotification)

Related

Not getting APNS Device token on ios 13

I have issue related to APNS device token . Before I was using Xcode 10.2 and iOS 12.1. At this moment I used to get the device token in delegate method
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
I am registering for APNS like this and it was working fine.
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){
if(!error){
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
}];
Now when installed iOS 13 to my iPhone device and using Xcode 11 , the delegate method didRegisterForRemoteNotificationsWithDeviceToken is not called. Unable to understand this problem .
I have already done research over this , I know there are some changes in getting token from the delegate method but in my case delegate method is not even called. Again it's working fine for iOS 12.
Just reboot your iPhone. It's as simple as that and in 90% of cases it will solve your problem.
Logon on https://appleid.apple.com/, then open url "https://developer.apple.com/account/ios/identifier/bundle"
or "https://developer.apple.com/account/resources/certificates/list".
First, Create two New Certificates:
(1)Apple Development
Sign development versions of your iOS, macOS, tvOS, and watchOS apps. For use in Xcode 11 or later.
(2)Apple Distribution
Sign your apps for submission to the App Store or for Ad Hoc distribution. For use with Xcode 11 or later.
Then find menu "Identifiers" via url "https://developer.apple.com/account/resources/identifiers/list".
Edit your Identifiers of your app, make sure that Development SSL Certificate & Production SSL Certificate is added to the Push Notifications.
Next, open menu "Profiles" via url "https://developer.apple.com/account/resources/profiles/list".
Make sure that the Certificates as type of DistributionFor which will be used in Xcode 11 or late, and save
Lastly, download the Provisioning Profile file and the CA Certificates files created to your MAC, which will be added to XCode and key-chain application by double click the files separately.
What's more, remember to reboot your cell phone, and make sure that you had setup the remote notification correctly.
I also faced the same problem. I tried many scenarios. I got success after doing the below steps:
Restarted device
Called the registerForRemoteNotifications
method in the main thread.
In my case, I was getting a device token, but there is a delay in response (I think due to registering remote notifications in a background thread). But after moving [[UIApplication sharedApplication] registerForRemoteNotifications] in the main thread, all works fine.
Here is my code:
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = delegate;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){
if(!error){
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] registerForRemoteNotifications];
[self callCompletion:TRUE completion:completion];
});
}
}];
Hope this will help.
I just solved this problem this way following below steps.
Add some print in didRegisterForRemoteNotificationsWithDeviceToken method and keep devices connected.
Went to the target capabilities.
Turn the Push Notification Off
Build & Run the app on device and wait.
Then check the console you got Fail push notification error message.
Stop running the app.
Turn the Push Notification On again.
Goto https://developer.apple.com/ Choose Account -> Certificates, Identifiers & Select your project ProvisionalProfiles -> Keys ->click on edit and save after that download provisonal profile and double click on it.
Build & Run the app on device.
Then its working fine.
I hope this help someone.
It is related to DeviceSupport missing in your XCode installation, for platform version used by your deploy device.
In my case, the 13.1 platform were missing.
To solve, just add the DeviceSupports in folder
Xcode.app/Contents/Develper/Platforms/iPhoneOS.platform/DeviceSupport
You can download missing DeviceSupport from:
https://github.com/iGhibli/iOS-DeviceSupport/tree/master/DeviceSupport
Try this.
Remove your application.
Reboot your phone.
Build and Run(reinstall your application) on your device.
It worked for me.

App not showing same result as Xcode simulator

I am new to Xcode and app programming and developed a small app to get certain calendar events and present them in a NSTableview.
The program is working fine in my Xcode simulator.
However when I build for running and start the App on my iMac, is is not returning any calendar events. Just runs and ends without any errors.
What am I missing here?
Problem was solved by adding [store requestAccessToEntityType:(EKEntityTypeEvent) completion:^(BOOL granted, NSError *error) after the allocation of the EKEventStore.

MKMapView not Rendering in iOS 8 or later

I'm having an issue in MKMapView in iOS 8.x.x. Application works fine iOS 7.x.x but not in iOS 8.x.x. On device it shows only annotations but no map behind.
I tried to forcefully Reset my Device as well but no luck.
I added these 2 Values in info.plist as well as it was a requirement for iOS 8 and onwards
<key>NSLocationAlwaysUsageDescription</key>
<string>Location is required to find out where you are</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location is required to find out where you are</string>
and added this lines of code in my Viewdidload.
// Check for iOS 8. Without this guard the code will crash with "unknown selector" on iOS 7.
if ([self.locationManager respondsToSelector:#selector(requestWhenInUseAuthorization)])
{
[self.locationManager requestWhenInUseAuthorization];
//[self.locationManager requestAlwaysAuthorization];
self.myMapView.showsUserLocation = YES;
}
By adding these 2 values in info.plist and the above lines of code, I'm able to get the User's Location and annotation in showing on map for user's location but Map is Blank.
Similar to this post:
MKMapView showing blank screen in iOS 8
Had the very same thing on IOS8.3 both sim and device.
Solved by running the system Maps App (it displayed empty grid as well) for a minute till it downloaded maps. After that my MKMapView started rendering as normal.
try add the delegate methods: - (void)mapViewWillStartLoadingMap:(MKMapView *)mapView;
- (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView;
- (void)mapViewDidFailLoadingMap:(MKMapView *)mapView withError:(NSError *)error;
and check the solution for you error message.
also check this solution i don't got rid of the grind but at least i got rid of the didFail error.
but seems to be an issue of iOS8 because on iOS8.3 works fine the same code.

UIPopover with UIDatePicker throws exception in iOS5.1

I have an enterprise iPad app that runs on several iPads of different vintage. All work fine except for one which is the only 1st generation iPad in the group. This iPad is running iOS 5.1.1. The app uses a UIPopoverController in several places and all work fine on this iPad except for the one that I last created.
Using the iPad 5.1 Simulator I was able to duplicate the problems…
The app crashes when trying to open a UIPopoverController which contains a UIViewController contining a UIDatePicker and a UIButton. The exception reads…
* Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint'
Here is the code I am using up to the line that throws the exception…
DatePickerPopOverViewController *datePickerViewController =[[DatePickerPopOverViewController alloc] init];
datePickerViewController.defaultDate = lastPopoverDate;
datePickerViewController.buttonTitle = #"Get Schedule";
datePickerViewController.delegate = self;
UIPopoverController *datePickerPopOver = [[UIPopoverController alloc] initWithContentViewController:datePickerViewController];
I am pretty sure that all of the elemnts involved are available in iOS5.1. Any suggestions would be greatly appreciated.
John
You can not use autolayout below iOS 6.0. The exception you are seeing is a result of this. NSLayoutConstraint is the class used to define interface element relationships when using autolayout.
To continue to target versions below iOS 6.0, simply uncheck "Use Autolayout" in the IB interface.

iOS App Crashing on iOS 4.2 but not 4.0, simulator not showing logs

Using XCode 3.2.5 I can run my application on iOS Simulator using the 4.2 SDK. However, it crashes on the following function, more specifically, the presentModalViewController call:
- (void)login {
//check to see if they logged in correctly here
/*UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:#"Login Failed!"
delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];*/
[self presentModalViewController:self.accountsViewController animated:YES];
}
However, on XCode 4 Dev Preview, I can't even access 4.2 SDK in the Simulator, so I'm forced to use 4.0 SDK. In 4.0, that function works find and as expected. I have two issues:
Why is the 4.2 SDK in the Simulator not reporting the reason it crashed in XCode 3.2.5? It used to be that when my app would crash in debugging mode in the Simulator, XCode would pop up the reason. However, it's not anymore.
Why would that simple line crash in 4.2 but not 4.0. Could it be the different XCode versions?
It was some sort of weird issue between XCode version. I recreated the whole add using solely XCode 3.2.5 and the same exact code now works.

Resources