WLGlobals.h 6.23 KB
/*
 Copyright 2010-2016 Warply Inc. All rights reserved.

 Redistribution and use in source and binary forms, without modification,
 are permitted provided that the following conditions are met:

 1. Redistributions of source code must retain the above copyright notice, this
 list of conditions and the following disclaimer.

 2. Redistributions in binaryform must reproduce the above copyright notice,
 this list of conditions and the following disclaimer in the documentation
 and/or other materials provided with the distribution.

 THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
 EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

///////////////////////////////////////////////////////////////////////////////
// Base URL
//#define WARP_PRODUCTION_BASE_URL       @"https://engage-stage.warp.ly"
//#define WARP_HOST                      @"engage-stage.warp.ly"
//#define WARP_ERROR_DOMAIN              @"engage-stage.warp.ly"
extern NSString*  WARP_PRODUCTION_BASE_URL;
extern NSString*  WARP_HOST;
extern NSString*  WARP_ERROR_DOMAIN;
extern NSString*  MERCHANT_ID;
extern NSString*  LANG;
#define WARP_PAGE_URL_FORMAT           @"%@/api/session/%@"
#define WARP_IMAGE_URL_FORMAT          @"%@/api/session/logo/%@"

///////////////////////////////////////////////////////////////////////////////
// Settings
#ifdef _WL_VERSION
#define WL_VERSION @ _WL_VERSION
#else
#define WL_VERSION @ "3.2.0a"
#endif

#define GEOFENCING_POIS_ENABLED @"GEOFENCING_POIS_ENABLED"
#define WL_IOS_LOCATION_FOREGROUND_MODE @"IOS_LOCATION_FOREGROUND_MODE"
#define WL_IOS_LOCATION_BACKGROUND_MODE @"IOS_LOCATION_BACKGROUND_MODE"
#define WL_IOS_GEOFENCING_ENABLED @"IOS_GEOFENCING_ENABLED"
#define WL_IOS_FOREGROUND_DISTANCE_FILTER @"IOS_FOREGROUND_DISTANCE_FILTER"
#define WL_IOS_BACKGROUND_DISTANCE_FILTER @"IOS_BACKGROUND_DISTANCE_FILTER"
#define WL_DEVICE_INFO_ENABLED @"DEVICE_INFO_ENABLED"
#define WL_OFFERS_ENABLED @"OFFERS_ENABLED"
#define WL_CONSUMER_DATA_ENABLED @"CONSUMER_DATA_ENABLED"
#define WL_USER_SESSION_ENABLED @"USER_SESSION_ENABLED"
#define WL_CUSTOM_ANALYTICS_ENABLED @"CUSTOM_ANALYTICS_ENABLED"
#define WL_USER_TAGGING_ENABLED @"USER_TAGGING_ENABLED"
#define WL_APPLICATION_DATA_ENABLED @"APPLICATION_DATA_ENABLED"
#define WL_WARPLY_ENABLED @"WARPLY_ENABLED"
#define WL_FEATURES_CHECK_INTERVAL @"FEATURES_CHECK_INTERVAL"
#define WL_LIFECYCLE_ANALYTICS_ENABLED @"LIFECYCLE_ANALYTICS_ENABLED"
#define WL_IOS_LOCATION_FOREGROUND_DESIRED_ACCURACY @"IOS_LOCATION_FOREGROUND_DESIRED_ACCURACY"
#define WL_IOS_LOCATION_BACKGROUND_DESIRED_ACCURACY @"IOS_LOCATION_BACKGROUND_DESIRED_ACCURACY"
#define WL_IOS_DEVICE_IS_WARPED @"is_warped"
#define WL_IOS_DEVICE_HAS_DEVICE_INFO @"has_device_info"
#define WL_IOS_DEVICE_HAS_APPLICATION_INFO @"has_application_info"
#define WL_FEATURE_IS_DISABLED_WITH_KEY(KEY) \
       ([[NSUserDefaults standardUserDefaults] boolForKey:KEY] == NO \
     && [[NSUserDefaults standardUserDefaults] objectForKey:KEY] != nil) \

#define WL_WARP_NOTIFICATIONS_ENABLED @"warp_enabled"
#define WL_APPLICATION_DATA @"application_data"
#define WL_DEVICE_STATUS @"device_status"
#define WL_BEACON_ENABLED @"BEACON_ENABLED"
#define WL_BEACON_TIME_INTERVAL_TO_RESEND @"BEACON_TIME_INTERVAL_TO_RESEND"

///////////////////////////////////////////////////////////////////////////////
// Logging
#ifdef DEBUG
#define WLLOG(xx, ...)  NSLog(@"%s(%d): " xx, __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else   
#define WLLOG(xx, ...)  ((void)0)
#endif // #ifdef DEBUG

///////////////////////////////////////////////////////////////////////////////
// Version Interface
#define WL_VERSION_INTERFACE()                                      \
+ (NSString *)get;     

#define WL_VERSION_IMPLEMENTATION(VERSION_STR)                      \
+ (NSString *)get {                                                 \
    return VERSION_STR;                                             \
}                                                                   \

///////////////////////////////////////////////////////////////////////////////
// System Versioning
#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

///////////////////////////////////////////////////////////////////////////////
// Enum Versioning
#ifdef __IPHONE_6_0 // iOS6 and later
#   define WLTextAlignmentCenter      NSTextAlignmentCenter
#   define WLTextAlignmentLeft        NSTextAlignmentLeft
#   define WLTextAlignmentRight       NSTextAlignmentRight
#   define WLTextTruncationTail       NSLineBreakByTruncatingTail
#   define WLTextTruncationMiddle     NSLineBreakByWordWrapping
#   define WLLineBreakByWordWrapping  NSLineBreakByWordWrapping
#else // older versions
#   define WLTextAlignmentCenter      UITextAlignmentCenter
#   define WLTextAlignmentLeft        UITextAlignmentLeft
#   define WLTextAlignmentRight       UITextAlignmentRight
#   define WLTextTruncationTail       UILineBreakModeTailTruncation
#   define WLTextTruncationMiddle     UILineBreakModeMiddleTruncation
#   define WLLineBreakByWordWrapping  UILineBreakModeWordWrap
#endif