Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

integration of store view controller into PHContentView launch dispat…

…ch handler
  • Loading branch information...
commit 4031f6f765618eca98d56ff452a1ceb4f46ce601 1 parent 62b8804
Jesus Fernandez authored
6 WaterWorks/content-subcontent.json
... ... @@ -1,7 +1,7 @@
1 1 {
2 2 "errobj": null,
3 3 "response": {
4   - "url": "http://localhost/~jesus/templates/src/html/promo.html",
  4 + "url": "http://media.playhaven.com/content-templates/1cca6f60ca2dcf4aa2dbf7fde89c1ef3810ab15a/html/promo.html",
5 5 "frame": {
6 6 "PH_LANDSCAPE": {
7 7 "y": 10,
@@ -32,7 +32,9 @@
32 32 "buy_dispatch": {
33 33 "type": "launch",
34 34 "parameters": {
35   - "url": "http://api2.betahaven.com/v3/publisher/dismiss?ordinal=0&nonce=62162814&cp=2596&ad_game_id=2571&ts=1328300403.02&impression_type=cpi&placement_tag=game_launch&content_type=interstitial_ad&signature=eb8226da0f90612749eeeb09cb7f6c9abf51dd84&device=6FE3F439-6D7F-5B85-8136-E90746673D2F&game_id=2108&content_id=1000127&resolution=buy&at=4"
  35 + "url": "http://api2.betahaven.com/v3/publisher/dismiss?ordinal=0&nonce=62162814&cp=2596&ad_game_id=2571&ts=1328300403.02&impression_type=cpi&placement_tag=game_launch&content_type=interstitial_ad&signature=eb8226da0f90612749eeeb09cb7f6c9abf51dd84&device=6FE3F439-6D7F-5B85-8136-E90746673D2F&game_id=2108&content_id=1000127&resolution=buy&at=4",
  36 + "iTunesID":"326987512",
  37 + "internal":"1"
36 38 }
37 39 },
38 40 "description": "Fight other mobsters in the most best multiplayer game ever!",
1  src/PHContentView.h
@@ -8,6 +8,7 @@
8 8 #import <Foundation/Foundation.h>
9 9 #import <UIKit/UIKit.h>
10 10 #import <QuartzCore/QuartzCore.h>
  11 +#import <StoreKit/StoreKit.h>
11 12 #import "PHURLLoader.h"
12 13 @class PHContent;
13 14 @class PHContentView;
21 src/PHContentView.m
@@ -14,6 +14,7 @@
14 14 #import "SDURLCache.h"
15 15 #import "PHUrlPrefetchOperation.h"
16 16 #import "PHPurchase.h"
  17 +#import "PHStoreProductViewControllerDelegate.h"
17 18
18 19 #define MAX_MARGIN 20
19 20
@@ -528,7 +529,14 @@ -(void)handleLaunch:(NSDictionary *)queryComponents callback:(NSString *)callbac
528 529 PHURLLoader *loader = [[PHURLLoader alloc] init];
529 530 loader.targetURL = [NSURL URLWithString:urlPath];
530 531 loader.delegate = self;
531   - loader.context = [NSDictionary dictionaryWithObject:callback forKey:@"callback"];
  532 + loader.context = [NSDictionary dictionaryWithObjectsAndKeys:
  533 + callback,@"callback",
  534 + queryComponents,@"queryComponents",
  535 + nil];
  536 +
  537 + BOOL shouldUseInternal = [[queryComponents valueForKey:@"internal"] boolValue] && ([SKStoreProductViewController class] != nil);
  538 + loader.opensFinalURLOnDevice = !shouldUseInternal;
  539 +
532 540 [loader open];
533 541 [loader release];
534 542 }
@@ -592,10 +600,19 @@ -(BOOL)sendCallback:(NSString *)callback withResponse:(id)response error:(id)err
592 600 #pragma mark PHURLLoaderDelegate
593 601 -(void)loaderFinished:(PHURLLoader *)loader{
594 602 NSDictionary *contextData = (NSDictionary *)loader.context;
  603 + NSString *callback = [contextData valueForKey:@"callback"];
  604 + NSDictionary *queryComponents = [contextData valueForKey:@"queryComponents"];
  605 +
595 606 NSDictionary *responseDict = [NSDictionary dictionaryWithObjectsAndKeys:
596 607 [loader.targetURL absoluteString], @"url",
597 608 nil];
598   - [self sendCallback:[contextData valueForKey:@"callback"]
  609 +
  610 + BOOL shouldUseInternal = [[queryComponents valueForKey:@"internal"] boolValue] && ([SKStoreProductViewController class] != nil);
  611 + if (shouldUseInternal) {
  612 + [[PHStoreProductViewControllerDelegate getDelegate] showProductId:[queryComponents valueForKey:@"iTunesID"]];
  613 + }
  614 +
  615 + [self sendCallback:callback
599 616 withResponse:responseDict
600 617 error:nil];
601 618 }

0 comments on commit 4031f6f

Please sign in to comment.
Something went wrong with that request. Please try again.