libPayPalEC.a without uniqueIdentifier? - ios

today I've tried to send my updated app and the apple declined my app for using uniqueIdentifier. After some research I found, that libPayPalEC.a is using uniqueIdentifier 3 times.
Via terminal: strings .Lib/PayPal/libPayPalEC.a | grep uniqueIdentifier
Does any one now where I can download updated library? I was looking everywhere...
Thank you,

Please refer to the issue here on github: https://github.com/paypal/PayPal-iOS-SDK/issues/13

After some reasearch and great answer on github: https://github.com/paypal/PayPal-iOS-SDK/issues/13#issuecomment-17882240 I've removed paypal library, removed deviceToken generation and the PayPal mobile is working!
How to use PayPal payment without library:
You need to create the payment process on the backend (like PHP) and in the iOS app just open the web view with URL to your backend. To process success or error handle the web view request so you can catch link like error, cancel or success (the pages, which the backend redirects).
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSString *urlString = [[request.URL absoluteString] lowercaseString];
if (urlString.length > 0) {
//80 is the default HTTP port.
//The PayPal server may add the default port to the URL.
//This will break our string comparisons.
if ([request.URL.port intValue] == 80) {
urlString = [urlString stringByReplacingOccurrencesOfString:#":80" withString:#""];
}
NSLog(#"URL %#",urlString);
if ([urlString rangeOfString:#"success"].location != NSNotFound) {
// handle error
if (visible) {
[self dismissViewControllerAnimated:YES completion:complete];
} else {
dismissOnAppear = YES;
}
return FALSE;
} else if ([urlString rangeOfString:#"cancel"].location != NSNotFound) {
// handle error
if (visible) {
[self dismissViewControllerAnimated:YES completion:complete];
} else {
dismissOnAppear = YES;
}
return FALSE;
} else if ([urlString rangeOfString:#"error"].location != NSNotFound) {
// handle error
if (visible) {
[self dismissViewControllerAnimated:YES completion:complete];
} else {
dismissOnAppear = YES;
}
return FALSE;
}
}
return TRUE;
}
On the backend handling you don't need to sent dirt token (from the iOS library) any more, you just work with token from paypal as the standard way.
As the payment method use _express-checkout not _express-checkout-mobile and don't send drt as deviceToken.

Related

i am trying to share video to twitter from my iOS app but it keep asking login

- (void) share:(NSString*)filename {
BOOL status = [[TwitterVideoUpload instance] setVideo:filename];
if (status == FALSE) {
[self addText:#"Failed reading video file"];
return;
}
status = [[TwitterVideoUpload instance] upload:^(NSString* errorString)
{
NSString* printStr = [NSString stringWithFormat:#"Share video %#: %#", filename,(errorString == nil) ? #"Success" : errorString];
[self addText:printStr];
}];
if (status == FALSE) {
[self addText:#"No Twitter account. Please add twitter account to Settings app."];
}
}
this is my code, even after login into twitter in my simulator and browser it keep saying "Not logged in". Any solution?
According to the ReadMe document for the TwitterVideoUpload repo:
Twitter username + password must be provided to iOS Settings app
Logging in via Mobile Safari isn't going to do it.
You need to use iOS Settings to authenticate to Twitter.

How to test the availability of URL or NOT?

I'm not found simple solution for this question on SO.
I need simple check logic for my URL and return YES - if available or NO - if not.
What i found:
-(BOOL)connectedToNetwork {
NSURL* url = [[NSURL alloc] initWithString:#"http://google.com/"];
NSData* data = [NSData dataWithContentsOfURL:url];
if (data != nil)
return YES;
return NO;
}
founded this
But i need more correctly answer.
UPD
I found SimplePing by Apple.
UPD1
Found answer on SO Thx all!
UPD2
Better solution SimplePingHelper required SimplePing:
- (void)tapPing {
[SimplePingHelper ping:#"www.google.com"
target:self sel:#selector(pingResult:)];
}
- (void)pingResult:(NSNumber*)success {
if (success.boolValue) {
[self log:#"SUCCESS"];
} else {
[self log:#"FAILURE"];
}
}
The preferred approach is trying to connect, and if that fails due to the host is not reachable check and monitor the network state. See Reachability. If the network state indicates that a host can be possibly reached, try again.
There are also a couple of third party libs that implement a handy API over Apple's Reachability interface.
I use AFNetworking to check reachability.
Pod file: pod "AFNetworking"
You have to include AFNetworkReachabilityManager.h in the file you want to use it.
This is a sample, basic code to check reachability.
// -- Start monitoring network reachability (globally available) -- //
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
NSLog(#"Reachability changed: %#", AFStringFromNetworkReachabilityStatus(status));
switch (status) {
case AFNetworkReachabilityStatusReachableViaWWAN:
case AFNetworkReachabilityStatusReachableViaWiFi:
// -- Reachable -- //
NSLog(#"Reachable");
break;
case AFNetworkReachabilityStatusNotReachable:
default:
// -- Not reachable -- //
NSLog(#"Not Reachable");
break;
}
}];
A valid URL is made of these characters :
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]#!$&'()*+,;=
You simply need to make a String checking function to validate your URL's characters are falling in or out.
Its was simple:
-(BOOL)connectedToNetwork {
NSURL* url = [[NSURL alloc] initWithString:#"http://google.com/"];
NSData* data = [NSData dataWithContentsOfURL:url];
if (data != nil)
return YES;
return NO;
}
founded this

AFNetworking + cocoapods + user session expiration monitoring

I have a client-server application that has a server singleton in it that is a subclass of AFHTTPSessionManager which was installed using cocoapods. When user is logging in they have their session cookie stored and they can perform different actions that require active session without providing their credentials more than once while the session is active. I have something around 50+ server calls that require user to be authenticated and which can return a JSON response stating that user's session is no longer valid and needs to be refreshed - by this event I should drop user out to login screen and ask them to re-login. I know that there's a method somewhere in the AFNetworking core that's processing raw responses for all the GET and POST methods before turning them into a responseObject of the id type but I cannot use it since I'm using cocoapods and can't really modify the core of a pod (I'm using git and pods aren't included in the commits). The question is - how do I handle user session expiration event centralized, not repeating it throughout 50+ different method calls?
I don't know if this is the best way or not, but I have solved this by creating a unified method to parsing error responses from server and put the check on whether user is authenticated or not into it like below and post an NSNotification I post when user logs out via logout button in app:
// in context of creating a request
success:^(NSURLSessionDataTask *task, id responseObject) {
NSString *errors = [self errors:responseObject[#"errors"]];
}
- (NSString *)errors:(id)errors
{
NSString *errMsg = nil;
if ([errors isKindOfClass:[NSDictionary class]]) {
errMsg = #"";
for (NSString *key in errors) {
errMsg = [errMsg stringByAppendingFormat:#"%#: ", key];
errMsg = [errMsg stringByAppendingString:[[errors objectForKey:key] componentsJoinedByString:#" "]];
errMsg = [errMsg stringByAppendingString:#"\n"];
}
}
else if ([errors isKindOfClass:[NSError class]]) {
if (!self.reachabilityManager.reachable) {
errMsg = #"Host isn't reachable. Please make sure you have an active Internet connection and try again later.";
}
else {
errMsg = [errors localizedDescription];
}
}
else if ([errors isKindOfClass:[NSString class]]) {
if ([errors isEqualToString:#"Operation requires authorized access."]) {
[CPAlertManager showMessage:#"Please re-authenticate." withTitle:#"Session expired."];
[[NSNotificationCenter defaultCenter] postNotificationName:CPUserLoginStatusChanged
object:#{ #"CPUserLoginStatus" : #(CPUserLoginStatusLoggedOut) }];
}
else {
errMsg = errors;
}
}
return errMsg;
}

Phonegap iOS: InAppBrowser opens but clicking on link sometimes does not open the page and event "falls through" to main webView

I'm developing an iOS app using phonegap and HTML5.
After launchImage in app, I open InAppBrowser, which opens promptly.
But, tapping on links in it sometimes does not open the desired page and event "falls through" to main webView.
i.e., InAppBrowser is closed on tapping the link.
Please do help me out as I'm stuck with this for the past two days.
Try this one
Put this code in your MainViewController.m before #end tag
- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL];
// Intercept the external http requests and forward to Safari.app
// Otherwise forward to the PhoneGap WebView
if ([[url scheme] isEqualToString:#"http"] || [[url scheme] isEqualToString:#"https"]){
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else {
return [super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
}
}
Resolved this issue by bypassing the error code. It is a bit of dirty workaround but couldn't help it. In "CDVInAppBrowser.m", modified as below and InAppBrowser loads my url successfully.
- (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
{
//By passing error code
if(error.code == -999)
return;
// log fail message, stop spinner, update back/forward
NSLog(#"webView:didFailLoadWithError - %i: %#", error.code, [error localizedDescription]);
self.backButton.enabled = theWebView.canGoBack;
self.forwardButton.enabled = theWebView.canGoForward;
[self.spinner stopAnimating];
self.addressLabel.text = NSLocalizedString(#"Load Error", nil);
[self.navigationDelegate webView:theWebView didFailLoadWithError:error];
}

fetching yahoo contacts in iphone

I am following this link: https://github.com/yahoo/yos-social-objc for retrieving yahoo contacts.
After providing all the credentials (i.e secret key, consumer key, app id) it is going to browser for login. But after logged in, it's displaying this message:
To complete sharing of yahoo! info with xxxx, enter code xxxx into xxxx
So, I am not getting that where I should enter this code? And how will it redirect to my application.
Any help will be appreciated.
CloudSponge has an iOS widget for its contact importer. Visit our test drive page from your iOS device to see how it works.
I work for CloudSponge, please let me know if you have any questions.
You need to specify your callback url. By default it's "oob" and will give you the verifier code. It will be better if you present your own web view and monitor the verifier code through webview delegates. Here's how you do it.
YOSSession *yahooSession; //instance variable
- (IBAction)yahooButtonAction:(UIButton *)sender {
yahooSession = [YOSSession sessionWithConsumerKey:YAHOO_CONSUMER_KEY
andConsumerSecret:YAHOO_CONSUMER_SECRET
andApplicationId:YAHOO_APP_ID];
// try to resume a user session if one exists
BOOL hasSession = [yahooSession resumeSession];
if(hasSession == FALSE) {
[self fetchSession];
}else{
[self sendRequests];
}
}
-(void)fetchSession{
// create a new YOSAuthRequest used to fetch OAuth tokens.
YOSAuthRequest *tokenAuthRequest = [YOSAuthRequest requestWithSession:yahooSession];
// fetch a new request token from oauth.
YOSRequestToken *newRequestToken = [tokenAuthRequest fetchRequestTokenWithCallbackUrl:#"http://localhost"];
// if it looks like we have a valid request token
if(newRequestToken && newRequestToken.key && newRequestToken.secret) {
// store the request token for later use
[yahooSession setRequestToken:newRequestToken];
[yahooSession saveSession];
// create an authorization URL for the request token
NSURL *authorizationUrl = [tokenAuthRequest authUrlForRequestToken:yahooSession.requestToken];
[self presentWebViewForYahooWithAuthURL:authorizationUrl];
//present it in webview
} else {
// NSLog(#"error fetching request token. check your consumer key and secret.");
}
}
-(void) presentWebViewForYahooWithAuthURL:(NSURL *)url{
_yahooWebView = [[UIWebView alloc] initWithFrame:self.view.frame];
_yahooWebView.delegate=self; //so that we can observe the url for verifier
[_yahooWebView loadRequest:[NSURLRequest requestWithURL:url]];
[self.view addSubview:_yahooWebView];
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
NSString *requestString = request.URL.absoluteString;
if ([requestString rangeOfString:#"http://localhost"].length>0) {
NSRange verifierRange = [requestString rangeOfString:#"oauth_verifier="];
if (verifierRange.length>0) {
verifierRange.location =verifierRange.location+verifierRange.length;
verifierRange.length = requestString.length-verifierRange.location;
NSLog(#"Verifier => %#", [requestString substringWithRange:verifierRange]);
yahooSession.verifier=[requestString substringWithRange:verifierRange];
[self sendRequests];
}
return NO;
}
else{
return YES;
}
}

Resources