Where should I set KApiKey, KApiSecret, KToken and KURL in iOS SDK? - ios

I am integrating my application code with Payeezy iOS SDK. but could not find the file to set KApiKey, KApiSecret, KToken and KURL
#define KApiKey #"test_apikey_bA8hIqpzuAVW6itHqXsXwSl6JtFWPCA0"
#define KApiSecret #"test_apitsecret_YmI4YzA1NmRkZmQzMzA1ZmIZjYzwMWIzZThkMWU2NGRjZmI4OWE5NGRiMzM4NA=="
#define KToken #"test_merchant_token_fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6"
#define KURL #"https://api-cert.payeezy.com/v1/transactions"
Please let me know the file name to set the parameter ? do you have any application that I can use for Authorize Capture and Purchase void ?

Either put them in a file that needs them, or if you want it throughout the app, you would put them in a prefix header.
To create a precompiled header, first make a .pch file, add those defines, and follow this to add the pch to your project.

You can set these parameters in the ViewController.m file in the payeezy sdk. You can also do it in the client specific .m file if you are doing custom implementation.
Initialize PayeezySDK object with KApiKey, KApiSecret, KToken and KURL like below
// initialize Payeezy object with key,token and secret value
PayeezySDK* myClient = [[PayeezySDK alloc]initWithApiKey:KApiKey apiSecret:KApiSecret merchantToken:KToken url:KURL];
Following is the link to the payeezy integration for ios
https://github.com/payeezy/payeezy_ios/blob/master/guide/payeezy_iOS_SDK042015.pdf

Related

Cannot Invoke an Argument List type

I am trying to configure the iOS SDK from Zopim into my code. My iOS code is written in Swift and I've imported the framework of the SDK which is written in Obj C. I have created a bridging header and was able to import from the framework.
In order to be able to configure and connect with Zopim I need to include the following code in my Appdelegate.swift file.
Object C Code:
[ZDCChat configure:^(ZDCConfig *defaults) { defaults.accountKey =
#"you account key here"; }];
I have tried to convert the above code into Swift (code below) however I'm getting the following error - Cannot Invoke Configure with an argument list of type ZDCConfig
Swift code:
ZDCChat.configure({(defaults: ZDCConfig) in defaults.accountKey =
"you account key here"})
The ZDCConfig code include the following:
#interface ZDCConfig : ZDCSessionConfig
/** * The Zopim account key (must be set before a chat can be
started). */
The ZDCChat code include the following:
** * The core of the Chat SDK, all objects related to chat can be accessed * from here either directly or indirectly. */ #interface
ZDCChat : NSObject
/** * The chat session. */
Can anyone guide me as to what is causing the problem ?
I had to add a bridging header that contained these two lines-
#import <ZDCChat/ZDCChat.h>
#import <MobileCoreServices/MobileCoreServices.h>
and then I was able to make that call like this-
ZDCChat.configure {
defaults in
defaults.accountKey = ""
}
Hope this helps.

How to set up the iOS Telegram Source Code

Hi I have downloaded the iOS source code for iOS but for some reason I cannot seem to find the place where the API_ID is anywhere. Please can you tell me where this information is in the source code so I can add in my own.
Add a file called "config.h" beside Telegraph.xcodeproj and place this code in that:
#define SETUP_API_ID(apiId) apiId = YOUR_API_ID;
#define SETUP_API_HASH(apiHash) apiHash = YOUR_API_HASH;
Then replace YOUR_API_ID and YOUR_API_HASH with values obtained from telegram api support.
Then compile and enjoy it!
Try to use the project search and put API, it`ll return the files where is.

Configure device specific global instance variables

I'm currently writing a universal app, and would like to set certain parameters, such as standard button size, globally, depending on device. Currently I am using:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
iVar = 88;
}
else {
iVar = 44;
}
in various places. However, I'd like to run this only once, and set the ivar somewhere globally. I know I could do this in the app delegate, once the app initialises, and declare the variable in the header, but I'm wondering if there is a more elegant solution that is standard practice.
(I am aware that I could use the native image size using xcassets, but I'd like more control than this).
Create a class Global.h and declare all global variables in it. Keep only the header file and import the Global.h file in YourProject-Prefix.pch like this:
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "Global.h"
#endif
In order to define your global variables, simply open the Global file and put the following line of code, i.e:
#define __metricsTableRowHeight 45
#define __metricsTableSectionHeight 45
#define __metricsTableSectionButtonHeight 57

class method +setLoggingEnabled: not found

I am using Google Cloud Endpoint with iOS. I am trying to create the service object per the instructions at https://developers.google.com/appengine/docs/java/endpoints/consume_ios#Java_Creating_the_service_object. For the line of code [GTMHTTPFetcher setLoggingEnabled:YES]; xCode is showing the warning
class method '+setLoggingEnabled:' not found (return type defaults to 'id')
But when I look inside the .h file for GTMHTTPFetcher I can actually see the method as
#if STRIP_GTM_FETCH_LOGGING
// if logging is stripped, provide a stub for the main method
// for controlling logging
+ (void)setLoggingEnabled:(BOOL)flag;
#endif // STRIP_GTM_FETCH_LOGGING
and in the .m file it looks like this
#if STRIP_GTM_FETCH_LOGGING
+ (void)setLoggingEnabled:(BOOL)flag {
}
#endif // STRIP_GTM_FETCH_LOGGING
Also the class is generated by Google so...it should work (?)
Set as follows :
#define STRIP_GTM_FETCH_LOGGING 1
In the file that contains the following line of code:
[GTMHTTPFetcher setLoggingEnabled:YES];
Add the following importation:
#import "GTMHTTPFetcherLogging.h"
I just faced the same problem.
In my case, it was because I was using the GTMHTTPFetcher from the Google+ iOS SDK:
Adding required files to your iOS project (Point 2.)
I had set the header information as described (Copied below here for simplicity):
If you are using the Google+ iOS SDK, set up your Xcode project as follows:
In your Xcode project, go to the settings page for the target.
In the Build Settings tab, add the following item to Header Search Paths:
GOOGLE_PLUS_SDK_DIRECTORY/GoogleOpenSource.framework/Headers where
GOOGLE_PLUS_SDK_DIRECTORY is the directory where you installed the
Google+ iOS SDK.
(I have Google+ iOS SDK within my project so I am using: $(PROJECT_DIR)/MyProject/External/GoogleOpenSource.framework/Headers)
However to see the setLoggingEnabled method you will need to add -ObjC -all_load to Other Linker Flags

iOS and XCode: What is the best way to store connection settings (i.e. URLs) for an iOS app?

We started with #defines pointing our app to dev, qa and live API servers. Well, that's rather lazy, not to mention painful to manage.
I'm thinking of storing default URL/connection settings in a .plist and creating dev|stage|live build configurations that will use the corresponding .plist for connections.
Is there a cleaner way to do this?
How secure is a .plist?
Here's how I handle it.
I have a single file where i store information like this. Lets call this file Configuration{h,m}
Within my .h (header) file, i declare the constants like this:
#pragma mark - API
extern NSString * const kAPIHost;
extern NSString * const kAPIVersion;
Within my .m (implementation) file, I finish it off with this
#pragma mark - API
#if TARGET_IPHONE_SIMULATOR
NSString * const kAPIHost = #"http://localhost/";
#else
NSString * const kAPIHost = #"http://liveserver.com";
#endif
NSString * const kAPIVersion = #"v2/";
What happens here is, it checks to see if i'm running on the sim, if i am, then it uses localhost, if it's running on device, it uses the live server.
Finally, I import Configuration.h in my precompiled header (PCH) file.
#import Configuration.h
Now, this file is available throughout your application without needing to import it in every single file. I use it like this.
NSURL * url = [NSURL URLWithString:[kAPIHost stringByAppendingString:[kAPIVersion stringByAppendingString:#"apiEndPoint/"]]];
The comment that troop231 posted sounds very interesting though. Maybe something I can implement at some time in the future. Always looking for more secure ways to do things :)
You could store this in keychain - it's secure - but I don't know why You would want to do that.
You could use extern constants instead of defines:
extern NSString *const in a class.
You can use preprocessor directives to help You manage the addresses:
http://www.techotopia.com/index.php/Using_Objective-C_Preprocessor_Directives
You could create a singleton class that would for example read these urls from .plist at start and then hand it over to any class that is interested.
About security:
using singleton with .plist and shipping app would not reveal Your test / dev addresses.
using #define, externs and preprocessor directives i.e. #ifdef DEBUG would also not reveal Your dev / test addresses in production code.

Resources