TWTRComposer() Application crashes when I try to open Composer - swift

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")
}
}

Related

NSURLErrorDomain: -1003

I am getting an NSURLErrorDomain: -1003 while I am running my application in Xcode. I haven't seen this error on StackOverflow, any clue about this?
I am using Alamofire 4
func fetchAllPosts() {
Alamofire.request("http://www.somthing.com/wp-json/wp/v2/posts?categories_exclude=9").responseJSON
{ response in
if let data = response.data {
do {
let newPosts = try JSONDecoder().decode(Posts.self, from: data)
self.posts = newPosts.items
// Success
self.fetchAllPostsDidSucceed()
print("number of posts loaded: \(newPosts.items.count)")
}
[17655:2080758] [] nw_proxy_resolver_create_parsed_array PAC evaluation error: NSURLErrorDomain: -1003
-1003 is NSURLErrorCannotFindHost.
If you ever need to look up a NSURLError code in the future, press shift+command+o (the letter “oh”) in Xcode, search for NSURLError, unselect the “Swift” toggle in the upper right corner of the search box and choose/open NSURLError.h, and you’ll see all the codes that header file.
This particular error can be caused by any of a number of issues. For example, if this is a macOS app, you may want to go to your target settings, click on the “Capabilities” tag and make sure that “Outgoing Connections (Client)” is selected.

Logout sinch user in iOS

I'm working on call/video application. I'm using SINCH SDK and i successfully integrated in swift project and call video work fine but i have a problem that when user is logged out from application still received a notification, i don't know why i used this function to logout
func logOutSinchUser() {
if let client = self._client {
client.stopListeningOnActiveConnection()
client.terminate()
client.unregisterPushNotificationData()
}
self._client = nil
}
Anyone can help me please ?
Please try to unregister the push token first(unregisterPushNotificationDeviceToken if you use sinch managed push) before you terminate the sinch client.
Also use terminateGracefully instead, to give the SDK more time to handle the unregistration process before shut off.
Could be sth like:
func logOutSinchUser() {
if let client = self._client {
client.stopListeningOnActiveConnection()
client.unregisterPushNotificationDeviceToken()
client.terminateGracefully()
}
self._client = nil
}

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.

Chartboost with Swift - Interstitial: prefetch if NOT complete. wait... but no ad?

I am trying to integrate Chartboost ads in Swift into my project and have followed the tutorial verbatim:
https://answers.chartboost.com/hc/en-us/articles/205853276
Everything is imported and in App delegate I have:
Chartboost.startWithAppId(//stuff)
Chartboost.setShouldRequestInterstitialsInFirstSession(false)
Chartboost.cacheMoreApps(CBLocationHomeScreen)
//Chartboost
class func showChartboostAds()
{
Chartboost.showInterstitial(CBLocationHomeScreen);
}
func didFailToLoadInterstitial(location :String!, withError error: CBLoadError)
{
}
func didDismissInterstitial(location :String! )
{
if(location == CBLocationHomeScreen)
{
Chartboost.cacheInterstitial(CBLocationMainMenu)
}
else if(location == CBLocationMainMenu)
{
Chartboost.cacheInterstitial(CBLocationGameOver)
}
else if(location == CBLocationGameOver)
{
Chartboost.cacheInterstitial(CBLocationLevelComplete)
}
else if(location == CBLocationLevelComplete)
{
Chartboost.cacheInterstitial(CBLocationHomeScreen)
}
}
Then in my main view controlleR:
AppDelegate.showChartboostAds()
I have my app in test mode in the dashboard and am running on a real device but I just get Interstitial: prefetch if NOT complete. wait... in the console.
Why won't it show any ads?
Just an aside, the reason this solution works is because of the prefetch method. It seems when you call the ad the Chartboost prefetch isn't completing on time, which is causing the show call to fail.
Chartboost does have a delegate method that will give you the all-clear when prefetch completes, that may be worth a look: - (void)didPrefetchVideos;
Here's a link to the rest of the page.
Hope this helps.
I think you're trying to show the AD to quickly. Try delaying the AD, that solved it for me.

CoreMIDI app not showing in other software

I am playing around a bit with CoreMIDI in Swift on OSX, and got most of the things to work properly.
The only issue I have now is that my app is not seen by other software and apps and an available input/output. This is the case for in GarageBand, MIDIMonitor and the VVMidi test apps.
I tried multiple things, including this which seems to be the correct approach :
let clientCreateResult = MIDIClientCreate("MIDIApp", { (notification, _) -> Void in
print("Configuration Changed")
}, nil, &midiClient)
if (clientCreateResult != noErr) {
printError(clientCreateResult)
return;
}
let inputCreateResult = MIDIInputPortCreateWithBlock(midiClient, "MIDIApp In", &inputPort, MyMIDIReadBlock)
if (inputCreateResult != noErr) {
printError(inputCreateResult)
return;
}
let outputCreateResult = MIDIOutputPortCreate(midiClient, "MIDIAPP Out", &outputPort)
if (outputCreateResult != noErr) {
printError(inputCreateResult)
return;
}
Sadly no luck. I'm not sure what I'm doing wrong, I tried reproducing the exact same code as existing frameworks with no significant result.
I could really use some pointers as of why my app isn't listed in other ones.
Thanks!
Create a virtual destination. See the docs for MIDIDestinationCreateWithBlock