IOS Promotion

From AdLocus
Revision as of 00:25, 8 October 2014 by Sfchang (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

前言

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

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

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

開啟BACKGROUND MODE

  • 開啟專案, 選擇 [Info], 在 [Custom iOS Target Properties] 中加入 [Required background modes]
  • 續上,新增 [App downloads content from the network]


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
  • "YourActivity" 填入發送優惠通知時的主畫面 Activity.
  • 在該 Activity 加入下列程式碼
#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;
}
 
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif 
{
    [HyxenLibProMeHyXenOfflinePushService didReceiveLocalNotification:notif];
    [[UIApplication sharedApplication] cancelLocalNotification:notif];
}
 
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
    [HyxenLibProMeHyXenOfflinePushService performFetchWithCompletionHandler:completionHandler];
}
 
-(NSString *)AdLocusAppKey
{
    return @"71b5d613b42d91c3ce601f1238fa7fb16cc53c9a682d20e084c8692d0d44690f0a3e2b53a7cbf2b9";
}
 
- (void)dealloc 
{
    [super dealloc];
    [AdLocusPushService release]; 
}