Difference between revisions of "IOS Promotion"

From AdLocus
Jump to: navigation, search
(→‎開啟BACKGROUND MODE)
 
(11 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
啟動優惠通知服務,請將相關程式碼加在 AppDelegate 處。
 
啟動優惠通知服務,請將相關程式碼加在 AppDelegate 處。
  
−
我們建議您透過開啟BACKGROUND MODE提高您的收益,請根據APP屬性斟酌是否啟用。
+
<onlyinclude>
  
 
== 開啟BACKGROUND MODE ==
 
== 開啟BACKGROUND MODE ==
−
* 開啟專案, 選擇 [Info], 在 [Custom iOS Target Properties] 中加入 [Required background modes]
+
* 為了提高Promotion Ad的分潤,我們建議您開啟此模式
 +
* 步驟: 開啟專案, 選擇 [Info], 在 [Custom iOS Target Properties] 中加入 [Required background modes]
 
* 續上,新增 [App downloads content from the network]
 
* 續上,新增 [App downloads content from the network]
−
[[File:IOS_Add_File_5.jpg]]
+
  [[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:  
 
*  (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:  
−
** 加入 /* AdLocusPushService - Start */ ~ /* AdLocusPushService - End */  
+
** 加入 /* hyxenLibProMeOffPushService - Start */ ~ /* hyxenLibProMeOffPushService - End */  
 
* -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notif  
 
* -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notif  
 
* -(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
 
* -(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
Line 30: Line 36:
 
@interface AppDelegate : UIResponder <UIApplicationDelegate,HyXenProMeOffPushlineServiceDelegate>
 
@interface AppDelegate : UIResponder <UIApplicationDelegate,HyXenProMeOffPushlineServiceDelegate>
 
{
 
{
−
     HyxenLibProMeHyXenOfflinePushService *AdLocusPushService;
+
     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 *AdLocusPushService;
+
@property (nonatomic, strong) HyxenLibProMeHyXenOfflinePushService *hyxenLibProMeOffPushService;
  
 
@end
 
@end
Line 47: Line 53:
 
@implementation AppDelegate
 
@implementation AppDelegate
  
−
@synthesize AdLocusPushService;
+
@synthesize hyxenLibProMeOffPushService;
  
 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  
−
     /* AdLocusPushService - Begin */
+
     /* hyxenLibProMeOffPushService - Begin */
 
     NSString *sysVersion = [UIDevice currentDevice].systemVersion;
 
     NSString *sysVersion = [UIDevice currentDevice].systemVersion;
 
     CGFloat version = [sysVersion floatValue];
 
     CGFloat version = [sysVersion floatValue];
Line 65: Line 71:
 
     }     
 
     }     
 
      
 
      
−
     if (!AdLocusPushService)  
+
     if (!hyxenLibProMeOffPushService)  
 
     {
 
     {
−
         self.AdLocusPushService=[[HyxenLibProMeHyXenOfflinePushService alloc]init];
+
         self.hyxenLibProMeOffPushService=[[HyxenLibProMeHyXenOfflinePushService alloc]init];
−
         AdLocusPushService.delegate=self;
+
         hyxenLibProMeOffPushService.delegate=self;
−
         [AdLocusPushService applicationLauching];
+
         [hyxenLibProMeOffPushService applicationLauching];
−
         [AdLocusPushService setEnablePushService:YES];         
+
         [hyxenLibProMeOffPushService setEnablePushService:YES];         
 
     }
 
     }
−
     /* AdLocusPushService - End */
+
     /* hyxenLibProMeOffPushService - End */
 
      
 
      
  
Line 84: Line 90:
 
}
 
}
  
−
/* AdLocusPushService - Begin */
+
/* hyxenLibProMeOffPushService - Begin */
 
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notif  
 
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notif  
 
{
 
{
Line 102: Line 108:
 
     return @"71b5d613b42d91c3ce601f1238fa7fb16cc53c9a682d20e084c8692d0d44690f0a3e2b53a7cbf2b9";
 
     return @"71b5d613b42d91c3ce601f1238fa7fb16cc53c9a682d20e084c8692d0d44690f0a3e2b53a7cbf2b9";
 
}
 
}
−
/* AdLocusPushService - End */
+
/* hyxenLibProMeOffPushService - End */
  
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 17:17, 6 May 2015

前言

適地性優惠通知服務是依據全區定向或特定地理位置定向,提供您的使用者最適合的主動式訊息,同時具有高額的分潤收益。

啟動優惠通知服務,請將相關程式碼加在 AppDelegate 處。


開啟BACKGROUND MODE

  • 為了提高Promotion Ad的分潤,我們建議您開啟此模式
  • 步驟: 開啟專案, 選擇 [Info], 在 [Custom iOS Target Properties] 中加入 [Required background modes]
  • 續上,新增 [App downloads content from the network]
 IOS Add File 5.jpg


設定位置權限(此設定'不會'造成藍提示,相容iOS8)

  • 步驟: 開啟專案, 選擇 [Info], 在 [Custom iOS Target Properties] 中加入 [NSLocationAlwaysUsageDescription]
 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

  • 實作 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 */