Difference between revisions of "IOS Promotion"
From AdLocus
(Created page with "== 前言 == 適地性優惠通知服務是依據全區定向或特定地理位置定向,提供您的使用者最適合的主動式訊息,同時具有高額的分潤收...") |
|||
| (23 intermediate revisions by the same user not shown) | |||
| Line 4: | Line 4: | ||
啟動優惠通知服務,請將相關程式碼加在 AppDelegate 處。 | 啟動優惠通知服務,請將相關程式碼加在 AppDelegate 處。 | ||
| − | + | <onlyinclude> | |
== 開啟BACKGROUND MODE == | == 開啟BACKGROUND MODE == | ||
| − | * 開啟專案, 選擇 [Info], 在 [Custom iOS Target Properties] 中加入 [Required background modes] | + | * 為了提高Promotion Ad的分潤,我們建議您開啟此模式 |
| − | * 續上,新增 [App downloads content from the network] | + | * 步驟: 開啟專案, 選擇 [Info], 在 [Custom iOS Target Properties] 中加入 [Required background modes] |
| + | * 續上,新增 [App downloads content from the network] | ||
| + | [[File:IOS_Add_File_5.jpg]] | ||
| + | </onlyinclude> | ||
| + | == 設定位置權限(此設定'不會'造成藍提示,相容iOS8) == | ||
| + | * 步驟: 開啟專案, 選擇 [Info], 在 [Custom iOS Target Properties] 中加入 [NSLocationAlwaysUsageDescription] | ||
| + | [[File:IOS_Add_File_6.jpg]] | ||
| + | |||
| + | == 實作 == | ||
| + | * (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: | ||
| + | ** 加入 /* hyxenLibProMeOffPushService - Start */ ~ /* hyxenLibProMeOffPushService - End */ | ||
| + | * -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notif | ||
| + | * -(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler | ||
| + | * -(NSString *)AdLocusAppKey | ||
== AppDelegate.h == | == AppDelegate.h == | ||
| Line 23: | Line 36: | ||
@interface AppDelegate : UIResponder <UIApplicationDelegate,HyXenProMeOffPushlineServiceDelegate> | @interface AppDelegate : UIResponder <UIApplicationDelegate,HyXenProMeOffPushlineServiceDelegate> | ||
{ | { | ||
| − | HyxenLibProMeHyXenOfflinePushService * | + | HyxenLibProMeHyXenOfflinePushService *hyxenLibProMeOffPushService; |
} | } | ||
@property (nonatomic, strong) UIWindow *window; | @property (nonatomic, strong) UIWindow *window; | ||
@property (nonatomic, strong) ViewController *viewController; | @property (nonatomic, strong) ViewController *viewController; | ||
| − | @property (nonatomic, strong) HyxenLibProMeHyXenOfflinePushService * | + | @property (nonatomic, strong) HyxenLibProMeHyXenOfflinePushService *hyxenLibProMeOffPushService; |
@end | @end | ||
| Line 34: | Line 47: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | + | == AppDelegate.m == | |
| − | + | ||
<syntaxhighlight lang="objc"> | <syntaxhighlight lang="objc"> | ||
#import "AppDelegate.h" | #import "AppDelegate.h" | ||
| Line 41: | Line 53: | ||
@implementation AppDelegate | @implementation AppDelegate | ||
| − | @synthesize | + | @synthesize hyxenLibProMeOffPushService; |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | ||
| − | + | /* hyxenLibProMeOffPushService - Begin */ | |
| − | /* | + | |
NSString *sysVersion = [UIDevice currentDevice].systemVersion; | NSString *sysVersion = [UIDevice currentDevice].systemVersion; | ||
CGFloat version = [sysVersion floatValue]; | CGFloat version = [sysVersion floatValue]; | ||
| Line 60: | Line 71: | ||
} | } | ||
| − | if (! | + | if (!hyxenLibProMeOffPushService) |
{ | { | ||
| − | self. | + | self.hyxenLibProMeOffPushService=[[HyxenLibProMeHyXenOfflinePushService alloc]init]; |
| − | + | hyxenLibProMeOffPushService.delegate=self; | |
| − | [ | + | [hyxenLibProMeOffPushService applicationLauching]; |
| − | [ | + | [hyxenLibProMeOffPushService setEnablePushService:YES]; |
} | } | ||
| − | /* | + | /* hyxenLibProMeOffPushService - End */ |
| + | |||
// Initial View. | // Initial View. | ||
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; | self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; | ||
| Line 78: | Line 90: | ||
} | } | ||
| − | - (void)application:(UIApplication *) | + | /* hyxenLibProMeOffPushService - Begin */ |
| + | - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notif | ||
{ | { | ||
[HyxenLibProMeHyXenOfflinePushService didReceiveLocalNotification:notif]; | [HyxenLibProMeHyXenOfflinePushService didReceiveLocalNotification:notif]; | ||
| Line 84: | Line 97: | ||
} | } | ||
| + | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 | ||
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler | - (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler | ||
{ | { | ||
[HyxenLibProMeHyXenOfflinePushService performFetchWithCompletionHandler:completionHandler]; | [HyxenLibProMeHyXenOfflinePushService performFetchWithCompletionHandler:completionHandler]; | ||
} | } | ||
| + | #endif | ||
-(NSString *)AdLocusAppKey | -(NSString *)AdLocusAppKey | ||
| Line 93: | Line 108: | ||
return @"71b5d613b42d91c3ce601f1238fa7fb16cc53c9a682d20e084c8692d0d44690f0a3e2b53a7cbf2b9"; | return @"71b5d613b42d91c3ce601f1238fa7fb16cc53c9a682d20e084c8692d0d44690f0a3e2b53a7cbf2b9"; | ||
} | } | ||
| − | + | /* hyxenLibProMeOffPushService - End */ | |
| − | - | + | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 17:17, 6 May 2015
Contents
前言
適地性優惠通知服務是依據全區定向或特定地理位置定向,提供您的使用者最適合的主動式訊息,同時具有高額的分潤收益。
啟動優惠通知服務,請將相關程式碼加在 AppDelegate 處。
開啟BACKGROUND MODE
- 為了提高Promotion Ad的分潤,我們建議您開啟此模式
- 步驟: 開啟專案, 選擇 [Info], 在 [Custom iOS Target Properties] 中加入 [Required background modes]
- 續上,新增 [App downloads content from the network]
設定位置權限(此設定'不會'造成藍提示,相容iOS8)
- 步驟: 開啟專案, 選擇 [Info], 在 [Custom iOS Target Properties] 中加入 [NSLocationAlwaysUsageDescription]
實作
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
- 加入 /* hyxenLibProMeOffPushService - Start */ ~ /* hyxenLibProMeOffPushService - End */
- -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notif
- -(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
- -(NSString *)AdLocusAppKey
AppDelegate.h
- 實作 HyXenProMeOffPushlineServiceDelegate
- 宣告 HyxenLibProMeHyXenOfflinePushService
#import <UIKit/UIKit.h> #import "libAdLocus_SDK.h" @class ViewController; @interface AppDelegate : UIResponder <UIApplicationDelegate,HyXenProMeOffPushlineServiceDelegate> { HyxenLibProMeHyXenOfflinePushService *hyxenLibProMeOffPushService; } @property (nonatomic, strong) UIWindow *window; @property (nonatomic, strong) ViewController *viewController; @property (nonatomic, strong) HyxenLibProMeHyXenOfflinePushService *hyxenLibProMeOffPushService; @end
AppDelegate.m
#import "AppDelegate.h" #import "ViewController.h" @implementation AppDelegate @synthesize hyxenLibProMeOffPushService; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { /* hyxenLibProMeOffPushService - Begin */ NSString *sysVersion = [UIDevice currentDevice].systemVersion; CGFloat version = [sysVersion floatValue]; if (version >= 7.0) { [application setMinimumBackgroundFetchInterval:60 * 60]; } UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; if (localNotif) { [HyxenLibProMeHyXenOfflinePushService didReceiveLocalNotification:localNotif]; [[UIApplication sharedApplication] cancelLocalNotification:localNotif]; } if (!hyxenLibProMeOffPushService) { self.hyxenLibProMeOffPushService=[[HyxenLibProMeHyXenOfflinePushService alloc]init]; hyxenLibProMeOffPushService.delegate=self; [hyxenLibProMeOffPushService applicationLauching]; [hyxenLibProMeOffPushService setEnablePushService:YES]; } /* hyxenLibProMeOffPushService - End */ // Initial View. self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; self.viewController = [[[ViewController alloc] init]; self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; return YES; } /* hyxenLibProMeOffPushService - Begin */ - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notif { [HyxenLibProMeHyXenOfflinePushService didReceiveLocalNotification:notif]; [[UIApplication sharedApplication] cancelLocalNotification:notif]; } #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 - (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { [HyxenLibProMeHyXenOfflinePushService performFetchWithCompletionHandler:completionHandler]; } #endif -(NSString *)AdLocusAppKey { return @"71b5d613b42d91c3ce601f1238fa7fb16cc53c9a682d20e084c8692d0d44690f0a3e2b53a7cbf2b9"; } /* hyxenLibProMeOffPushService - End */

