Difference between revisions of "IOS Promotion"

From AdLocus
Jump to: navigation, search
(→‎開啟BACKGROUND MODE)
Line 7: Line 7:
 
<onlyinclude>
 
<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]]

Revision as of 13:12, 9 October 2014

前言

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

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

我們建議您透過開啟BACKGROUND MODE提高您的收益,請根據APP屬性斟酌是否啟用。

開啟BACKGROUND MODE

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

實作

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
    • 加入 /* AdLocusPushService - Start */ ~ /* AdLocusPushService - 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 *AdLocusPushService;
}
 
@property (nonatomic, strong) UIWindow *window;
@property (nonatomic, strong) ViewController *viewController;
@property (nonatomic, strong) HyxenLibProMeHyXenOfflinePushService *AdLocusPushService;
 
@end

AppDelegate.m

#import "AppDelegate.h"
#import "ViewController.h"
@implementation AppDelegate
 
@synthesize AdLocusPushService;
 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
 
    /* AdLocusPushService - 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 (!AdLocusPushService) 
    {
        self.AdLocusPushService=[[HyxenLibProMeHyXenOfflinePushService alloc]init];
        AdLocusPushService.delegate=self;
        [AdLocusPushService applicationLauching];
        [AdLocusPushService setEnablePushService:YES];         
    }
    /* AdLocusPushService - 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;
}
 
/* AdLocusPushService - 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";
}
/* AdLocusPushService - End */