iAd Crashing in 3.2 - iphone

I'm noticing my iAd is causing a crash on iOS 3.2. I am weak linking in the build settings. It crashes in my createAdBanner method
NSString *contentSize;
if (&ADBannerContentSizeIdentifierPortrait != nil) {
contentSize = UIInterfaceOrientationIsPortrait(self.interfaceOrientation) ? ADBannerContentSizeIdentifierPortrait : ADBannerContentSizeIdentifierLandscape;
}
else {
contentSize = UIInterfaceOrientationIsPortrait(self.interfaceOrientation) ? ADBannerContentSizeIdentifier320x50 : ADBannerContentSizeIdentifier480x32;
}
Here is the error that comes up.
This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 4681.
Assertion failed: (cls), function getName, file /SourceCache/objc4_Sim/objc4-427.1.1/runtime/objc-runtime-new.m, line 3939.
Assertion failed: (cls), function getName, file /SourceCache/objc4_Sim/objc4-427.1.1/runtime/objc-runtime-new.m, line 3939.
Current language: auto; currently objective-c
(gdb)
I thought you were able to run iAds on 3.2 if you weak linked. Any ideas or suggestions?

http://developer.apple.com/library/ios/#documentation/userexperience/Reference/ADBannerView_Ref/Reference/Reference.html
ADBannerView is available in 4.0 or later.
You won't be able to show ads in 3.2

Aside from weak-linking, you must check if the ad classes are available on the device. To do so, you can use the following to test for the existence of a class:
Class adClass = NSClassFromString(#"AdBannerView");
if(adClass){
//ads are available so optionally show them
}else{
// ads are not available
}
To check for a particular method, you would use this:
BOOL methodExists = [someObject respondsToSelector:#selector(selectorToTestName:)];
if(methodExists){
//Safe to call selector
}else{
//The selector doesn't exist in this version of iOS.
}
You could also just use the above statement, "inlining" the boolean check:
if([someObject respondsToSelector:#selector(selectorToTestName:)]){
//Safe to call selector
}else{
//The selector doesn't exist in this version of iOS.
}

ADBannerViewcan be used in 4.0 and above. See the apple documentation

use below link it is giving more clearly even to use in ios 3.0+ IAD Tutorial you have to import _weak_framework iAd in the linkingFlags wich is available in the targets.Once go through the link.

Related

TWTRComposer() Application crashes when I try to open Composer

I am having an issue with TWTRComposer. I installed TwitterKit using pods followed all other instructions i.e. updated info.Plist , AppDelegate and so on. I am using Swift. When I call the func that handles the code the app crashes here, sample code below. On the line where composer.show(from: self.navigationController!) the error message is Thread 1:EXC_BREAKPOINT(code=1, subcode=0x1024ff1ac) I have no clue what this means. Any explanation and help is appreciated.
let composer = TWTRComposer()
composer.setText("just setting up my Twitter Kit")
composer.setImage(UIImage(named: "twitterkit"))
// Called from a UIViewController
composer.show(from: self.navigationController!) { (result) in
if (result == .done) {
print("Successfully composed Tweet")
} else {
print("Cancelled composing")
}
}

iOS 10 app crashes when trying to save image to photo library

I'm trying to save an image to the photo library in Swift 3 (I'm working with Xcode 8).
ViewController Code:
func shareImage(image: UIImage) {
let items = [image]
var activityVC: UIActivityViewController = UIActivityViewController(activityItems: items, applicationActivities: nil)
let excludeActivities: [UIActivityType] = [UIActivityType.airDrop,
UIActivityType.assignToContact,
UIActivityType.addToReadingList,
UIActivityType.copyToPasteboard]
activityVC.excludedActivityTypes = excludeActivities
self.present(activityVC, animated: true, completion: nil)
}
When I run the application, and click on the button to take the screenshot (converting it to image, ..., that's all working perfectly), the app asks for permission to access the photo library, I tap the "OK" button, and then the app crashes. The image is not saved in the photo library.
The only clue I get from Xcode is the following:
2016-09-28 11:24:27.216043 Ajax Kids[4143:1545362] [error] error: -addPersistentStoreWithType:SQLite configuration:(null) URL:file:///var/mobile/Media/PhotoData/Photos.sqlite?readonly_shm=1 options:{
NSPersistentStoreFileProtectionKey = NSFileProtectionCompleteUntilFirstUserAuthentication;
NSReadOnlyPersistentStoreOption = 1;
NSSQLitePersistWALOption = 1;
NSSQLitePragmasOption = {
"journal_mode" = WAL;
};
} ... returned error Error Domain=NSCocoaErrorDomain Code=256 "The file couldn’t be opened." UserInfo={reason=Failed to access file: 1} with userInfo dictionary {
reason = "Failed to access file: 1";
}
2016-09-28 11:24:27.216433 Ajax Kids[4143:1545362] [Migration] Unexpected error opening persistent store <private>, cannot attempt migration <private>)
2016-09-28 11:24:27.216568 Ajax Kids[4143:1545362] [Migration] Failed to open store <private>. Requires update via assetsd (256: <private>)
Does anyone have any idea how to fix this?
Thanks in advance!
UPDATE
Sharing the image on Social Media works fine, so the problem is specified to saving the image in the photo library.
Add new records in your new InfoPlist.strings file.
<key>NSPhotoLibraryAddUsageDescription</key>
<string>$(PRODUCT_NAME)</string>
UPD: iOS 11 key
On iOS 11, there is a new property called NSPhotoLibraryAddUsageDescription, similar to NSPhotoLibraryUsageDescription. See https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html
Try to force request permissions like this:
PHPhotoLibrary.requestAuthorization { status in
if status == .authorized {
//do things
}
}
do not forget import Photos. Hope this helps.
I found the culprit in my particular case. We are using Leanplum for analytics and push notifications. The Leanplum.syncResourcesAsync method was causing the opening of the photo library to crash. It took a couple of days to find as I wasn't aware Leanplum was doing anything to hook into a user's photo library... which in itself is concerning.
We weren't using the functionality this particular method brings, so were able to just remove the method call and the photo library stopped crashing.

Ionic scrollTop "Cannot read property 'scrollTo' of null" (still exists in 1.0.0-rc.1)

This bug was referred to here: in ionic changing route causes "TypeError: Cannot read property 'scrollTo' of null"
The answer says that this bug was fixed in beta-13, but I'm using 1.0.0-rc.1 and the bug still appears.
In my case, it the error is showing when navigating back to a page that uses $ionicScrollDelegate.scrollTop()
Is anyone else getting this error after updating to rc.1?
EDIT:
I find that if I do not call $ionicScrollDelegate.scrollTop() automatically when my view loads, the error does not come up. Should I be calling scrollTop() within a specific Ionic event that waits for the right time?
Had the same problem, even with v1.0.0 "uranium-unicorn".
Wrapping the scroll call into a $timeout helped - this is what it looks like in my code:
$timeout(function() {
$ionicScrollDelegate.scrollTo(scrollPosition.left, scrollPosition.top);
}, 0);
You can just put it in
$ionicPlatform.ready(function () {
$ionicScrollDelegate.scrollTop();
})
Im late to this but was getting the same error but by calling the scroll top element with:
$ionicScrollDelegate.scrollTop();
but rather:
var scrollTop = e.detail.scrollTop;
and fixed my by using the following:
var scrollTop = $ionicScrollDelegate.getScrollPosition().top;
Im also using js scrolling as it seems to work better with the scrolla-sista plugin so I have the following in my config block at the start of my app
$ionicConfigProvider.scrolling.jsScrolling(true);
where their docs state:
Whether to use JS or Native scrolling. Defaults to native scrolling. Setting this to true has the same effect as setting each ion-content to have overflow-scroll='false'.
I hope this helps someone
For what it's worth, I saw this solution on this thread here and it worked for me with version 1.0.0-beta.14
If upgrading to version 1.0.0-beta.14 is not an option, you can change the ionic-bundle.js file with the following:
Approximately Line 39910:
this.scrollTop = function(shouldAnimate) {
this.resize().then(function() {
if(typeof scrollView !== 'undefined' && scrollView !== null){
scrollView.scrollTo(0, 0, !!shouldAnimate);
}
});
};
And Approximately line 39813:
if (!angular.isDefined(scrollViewOptions.bouncing)) {
ionic.Platform.ready(function() {
if(!scrollView){
return;
}
scrollView.options.bouncing = true;
if(ionic.Platform.isAndroid()) {
// No bouncing by default on Android
scrollView.options.bouncing = false;
// Faster scroll decel
scrollView.options.deceleration = 0.95;
}
});
}
Please change
e.detail.scrollTop
to
e.target.scrollTop
then this will Work

How to make "SBAwayController * controller = [objc_getClass("SBAwayController") sharedAwayController]" working?

I want to check whether the screen is locked with private api.
And I get some code from google:
#import <SpringBoard/SpringBoard.h>
#import <SpringBoard/SBAwayController.h>
Class clsAway = objc_allocateClassPair(clsAlert, "SBAwayController", 0);
objc_registerClassPair(clsAway);
Class clsAwayController = objc_getClass("SBAwayController");
SBAwayController * controller = [clsAwayController sharedAwayController];
if ([controller isLocked]){
NSLog(#"double check Home ,now YES Lock");
}
else{
NSLog(#"double check Home ,now NO Lock");
}
To make these code to work, I download the private headers from kennytm's github and import SpringBoard.h and SBAwayController.h
Compile ok and run it on my iPhone 4S, it seems that I can get a non-nil pointer with objc_getClass("SBAwayController");
But the program crashed at line:
SBAwayController * controller = [clsAwayController sharedAwayController];
with an error: '+[SBAwayController sharedAwayController]: unrecognized selector sent to class 0x1456c0'
Any other works do I need to make these code to work?
I know that the usage of private api can cause the rejection from Apple, but I just want to know how to make it work. Thanks for any suggestions!
SBAwayController WAS NOT REMOVED IN iOS 5. How can you expect to use a SpringBoard method from another process? SpringBoard is NOT a framework. It's an executable.
I believe SBAwayController was removed in the iOS 5. I checked SpringBoard and it has only reminiscences of this class.
Victor is wrong. The class is still present in iOS 6
cy# c = SBAwayController.sharedAwayController;
#"<SBAwayController: 0x1c510580> <SBActivationContext: 0x1c50be50> activate: deactivate: "
cy# printMethods(SBAwayController);
[{selector:#selector(hasEverBeenLocked),implementation:0x109c49},{selector:#selector(activateLostModeForRemoteLock:),implementation:0x116505},{selector:#selector(unlockWithSound:),implementation:0x110835},{selector:#selector(frontLocked:animate:automatically:),implementation:0x1120d5},{selector:#selector(cancelDimTimer),implementation:0x11291d},{selector:#selector(activeAwayPluginController),implementation:0x116885},{selector:#selector(shouldShowInCallUI),implementation:0x116111
...

what dows TTIsPad() do in Xcode using Three20?

i'm using Three20 in XCode but i copied a piece of code like this:
if (TTIsPad()) {
SplitCatalogController* controller =
(SplitCatalogController*)[[TTNavigator navigator] viewControllerForURL:#"tt://catalog"];
SplitCatalogController* controller =
(SplitCatalogController*)[[TTNavigator navigator] viewControllerForURL:#"tt://catalog"];
TTDASSERT([controller isKindOfClass:[SplitCatalogController class]]);
map = controller.rightNavigator.URLMap;
}
But i don't know what does the function TTIsPad do, please help me.
It is a convenience method that returns true if the current device is an iPad, and false otherwise.
The source can be found here. It first checks whether the device is running iOS 3.2 or greater. If not, it returns false (iPads shipped with 3.2) If it is greater than 3.2, it returns the result of (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) which is true only if the device is an iPad.