diff --git a/platforms/ios/TDA-Planner.xcodeproj/project.pbxproj b/platforms/ios/TDA-Planner.xcodeproj/project.pbxproj index 6dc623f..c6439ed 100644 --- a/platforms/ios/TDA-Planner.xcodeproj/project.pbxproj +++ b/platforms/ios/TDA-Planner.xcodeproj/project.pbxproj @@ -5,9 +5,7 @@ }; objectVersion = 46; objects = { - /* Begin PBXBuildFile section */ - 09607C0167854D03B359D66D /* iAd.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 11C3E663D10E42C2AA763428 /* iAd.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; 151CD3675EFE4CBCB90F3C92 /* CDVStatusBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 911789424D564B9B8B774877 /* CDVStatusBar.m */; }; 1739A3ED180C5874004BA0E9 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1739A3EA180C5874004BA0E9 /* Default-568h@2x.png */; }; 1739A3EE180C5874004BA0E9 /* Default@2x~iPhone.png in Resources */ = {isa = PBXBuildFile; fileRef = 1739A3EB180C5874004BA0E9 /* Default@2x~iPhone.png */; }; @@ -43,8 +41,6 @@ 5AA0E66D1729F45B000DC89A /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AA0E66C1729F45B000DC89A /* OpenAL.framework */; }; 5AA0E66F1729F460000DC89A /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AA0E66E1729F460000DC89A /* ImageIO.framework */; }; 5B1594DD16A7569C00FEF299 /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B1594DC16A7569C00FEF299 /* AssetsLibrary.framework */; }; - 80AE4FAC0CD6442EA412EFC7 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE081411D12241128C8497EB /* AdSupport.framework */; }; - 932D15775E694CE088ECE176 /* CDViAd.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E817B805AC44525AD71F580 /* CDViAd.m */; }; F840E1F1165FE0F500CFE078 /* config.xml in Resources */ = {isa = PBXBuildFile; fileRef = F840E1F0165FE0F500CFE078 /* config.xml */; }; /* End PBXBuildFile section */ @@ -149,8 +145,6 @@ 305D5FD1115AB8F900A74A75 /* MobileCoreServices.framework in Frameworks */, 175334FA194F6D67007F5A72 /* FacebookSDK.framework in Frameworks */, 30E5649213A7FCAF007403D8 /* CoreMedia.framework in Frameworks */, - 80AE4FAC0CD6442EA412EFC7 /* AdSupport.framework in Frameworks */, - 09607C0167854D03B359D66D /* iAd.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -335,7 +329,7 @@ 29B97313FDCFA39411CA2CEA /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0510; + LastUpgradeCheck = 510; TargetAttributes = { 1D6058900D05DD3D006BFB54 = { DevelopmentTeam = 5TFUK958NL; @@ -431,7 +425,6 @@ 1D60589B0D05DD56006BFB54 /* main.m in Sources */, 1D3623260D0F684500981E51 /* AppDelegate.m in Sources */, 302D95F114D2391D003F00A1 /* MainViewController.m in Sources */, - 932D15775E694CE088ECE176 /* CDViAd.m in Sources */, 151CD3675EFE4CBCB90F3C92 /* CDVStatusBar.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/platforms/ios/TDA-Planner/Plugins/com.rjfun.cordova.plugin.iad/CDViAd.h b/platforms/ios/TDA-Planner/Plugins/com.rjfun.cordova.plugin.iad/CDViAd.h deleted file mode 100644 index af83c07..0000000 --- a/platforms/ios/TDA-Planner/Plugins/com.rjfun.cordova.plugin.iad/CDViAd.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// CDViAd.h -// iAd Plugin for PhoneGap/Cordova -// -// Created by shazron on 10-07-12. -// Copyright 2010 Shazron Abdullah. All rights reserved. -// Cordova v1.5.0 Support added 2012 @RandyMcMillan -// - -#import -#import -#import - -@interface CDViAd : CDVPlugin { - -} - -@property (nonatomic, retain) ADBannerView* bannerView; -@property (assign) BOOL bannerIsVisible; -@property (assign) BOOL bannerIsInitialized; -@property (assign) BOOL bannerAtTop; - -- (void) createBannerView:(CDVInvokedUrlCommand *)command; -- (void) showAd:(CDVInvokedUrlCommand *)command; - -@end diff --git a/platforms/ios/TDA-Planner/Plugins/com.rjfun.cordova.plugin.iad/CDViAd.m b/platforms/ios/TDA-Planner/Plugins/com.rjfun.cordova.plugin.iad/CDViAd.m deleted file mode 100644 index da73df3..0000000 --- a/platforms/ios/TDA-Planner/Plugins/com.rjfun.cordova.plugin.iad/CDViAd.m +++ /dev/null @@ -1,348 +0,0 @@ -// -// CDViAd.m -// Ad Plugin for PhoneGap -// -// Created by shazron on 10-07-12. -// Copyright 2010 Shazron Abdullah. All rights reserved. -// Cordova v1.5.0 Support added 2012 @RandyMcMillan -// Cordova v3.0.0 Support added 2013 @LimingXie - -#import "CDViAd.h" -#import -#import "MainViewController.h" - -@interface CDViAd() - -- (void) __prepare:(BOOL)atTop; -- (void) __showAd:(BOOL)show; -- (bool) __isLandscape; - -@end - - -@implementation CDViAd - -@synthesize bannerView; -@synthesize bannerIsVisible, bannerIsInitialized, bannerAtTop; - -#pragma mark - -#pragma mark Public Methods - -- (CDVPlugin *)initWithWebView:(UIWebView *)theWebView { - self = (CDViAd *)[super initWithWebView:theWebView]; - if (self) { - // These notifications are required for re-placing the ad on orientation - // changes. Start listening for notifications here since we need to - // translate the Smart Banner constants according to the orientation. - [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(deviceOrientationChange:) - name:UIDeviceOrientationDidChangeNotification - object:nil]; - } - return self; -} - -- (void) createBannerView:(CDVInvokedUrlCommand *)command -{ - CDVPluginResult *pluginResult; - NSString *callbackId = command.callbackId; - NSArray* arguments = command.arguments; - - NSUInteger argc = [arguments count]; - if (argc > 1) { - return; - } - - BOOL atTop = NO; - NSString* atTopValue = [arguments objectAtIndex:0]; - if( atTopValue ) atTop = [atTopValue boolValue]; - [self __prepare:atTop]; - - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; - [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; -} - -- (void) showAd:(CDVInvokedUrlCommand *)command -{ - CDVPluginResult *pluginResult; - NSString *callbackId = command.callbackId; - NSArray* arguments = command.arguments; - - NSUInteger argc = [arguments count]; - if (argc > 1) { - return; - } - - BOOL show = YES; - NSString* showValue = [arguments objectAtIndex:0]; - if( showValue ) show = [showValue boolValue]; - [self __showAd:show]; - - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; - [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; -} - -- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration -{ - Class adBannerViewClass = NSClassFromString(@"ADBannerView"); - if (adBannerViewClass && self.bannerView) { - - CGRect superViewFrame = self.webView.superview.frame; - if([self __isLandscape]) { - superViewFrame.size.width = self.webView.superview.frame.size.height; - superViewFrame.size.height = self.webView.superview.frame.size.width; - } - - CGRect adViewFrameNew = self.bannerView.frame; - adViewFrameNew.size = [self.bannerView sizeThatFits:superViewFrame.size]; - self.bannerView.frame = adViewFrameNew; - - [self resizeViews]; - } -} - -- (void) resizeViews -{ - Class adBannerViewClass = NSClassFromString(@"ADBannerView"); - if (adBannerViewClass && self.bannerView) { - - // If the ad is not showing or the ad is hidden, we don't want to resize anything. - BOOL adIsShowing = [self.webView.superview.subviews containsObject:self.bannerView] && - (! self.bannerView.hidden); - - // Handle changing Smart Banner constants for the user. - bool isLandscape = [self __isLandscape]; - - // iOS7 Hack, handle the Statusbar - MainViewController *mainView = (MainViewController*) self.webView.superview.window.rootViewController; - BOOL isIOS7 = ([[UIDevice currentDevice].systemVersion floatValue] >= 7); - CGFloat top = isIOS7 ? mainView.topLayoutGuide.length : 0.0; - - // Frame of the main container view that holds the Cordova webview. - CGRect superViewFrame = self.webView.superview.frame; - // Frame of the main Cordova webview. - CGRect webViewFrame = self.webView.frame; - CGRect bannerViewFrame = self.bannerView.frame; - - // Let's calculate the new position and size - CGRect superViewFrameNew = superViewFrame; - CGRect webViewFrameNew = webViewFrame; - CGRect bannerViewFrameNew = bannerViewFrame; - - if( isLandscape ) { - superViewFrameNew.size.width = superViewFrame.size.height; - superViewFrameNew.size.height = superViewFrame.size.width; - } - - if(adIsShowing) { - if(self.bannerAtTop) { - // move banner view to top - bannerViewFrameNew.origin.y = top; - // move the web view to below - webViewFrameNew.origin.y = top + bannerViewFrame.size.height; - } else { - // move web view to top - webViewFrameNew.origin.y = top; - // move the banner view to below - bannerViewFrameNew.origin.y = superViewFrameNew.size.height - bannerViewFrame.size.height; - } - - webViewFrameNew.size.width = superViewFrameNew.size.width; - webViewFrameNew.size.height = superViewFrameNew.size.height - bannerViewFrame.size.height - top; - - bannerViewFrameNew.origin.x = (superViewFrameNew.size.width - bannerViewFrameNew.size.width) * 0.5f; - - NSLog(@"webview: %d x %d, banner view: %d x %d", - (int) webViewFrameNew.size.width, (int) webViewFrameNew.size.height, - (int) bannerViewFrameNew.size.width, (int) bannerViewFrameNew.size.height ); - - self.bannerView.frame = bannerViewFrameNew; - - } else { - webViewFrameNew = superViewFrameNew; - webViewFrameNew.origin.y += top; - webViewFrameNew.size.height -= top; - - NSLog(@"webview: %d x %d", - (int) webViewFrameNew.size.width, (int) webViewFrameNew.size.height ); - - } - - self.webView.frame = webViewFrameNew; - } -} - -#pragma mark - -#pragma mark Private Methods - -- (void) __prepare:(BOOL)atTop -{ - NSLog(@"CDViAd Prepare Ad, bannerAtTop: %d", atTop); - - Class adBannerViewClass = NSClassFromString(@"ADBannerView"); - if (adBannerViewClass && !self.bannerView) { - self.bannerView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)]; - - CGRect superViewFrame = self.webView.superview.frame; - if([self __isLandscape]) { - superViewFrame.size.width = self.webView.superview.frame.size.height; - superViewFrame.size.height = self.webView.superview.frame.size.width; - } - - CGRect adViewFrameNew = self.bannerView.frame; - adViewFrameNew.size = [self.bannerView sizeThatFits:superViewFrame.size]; - self.bannerView.frame = adViewFrameNew; - - NSLog(@"x,y,w,h = %d,%d,%d,%d", - (int) adViewFrameNew.origin.x, (int) adViewFrameNew.origin.y, - (int) adViewFrameNew.size.width, (int) adViewFrameNew.size.height ); - - self.bannerView.delegate = self; - - self.bannerAtTop = atTop; - self.bannerIsVisible = NO; - self.bannerIsInitialized = YES; - - [self resizeViews]; - } -} - -- (void) __showAd:(BOOL)show -{ - NSLog(@"CDViAd Show Ad: %d", show); - - if (!self.bannerIsInitialized){ - [self __prepare:NO]; - } - - if (!(NSClassFromString(@"ADBannerView") && self.bannerView)) { // ad classes not available - return; - } - - if (show == self.bannerIsVisible) { // same state, nothing to do - if( self.bannerIsVisible) { - [self resizeViews]; - } - } else if (show) { - [[[super webView] superview] addSubview:self.bannerView]; - [[[super webView] superview] bringSubviewToFront:self.bannerView]; - [self resizeViews]; - - self.bannerIsVisible = YES; - } else { - [self.bannerView removeFromSuperview]; - [self resizeViews]; - - self.bannerIsVisible = NO; - } - -} - -- (bool)__isLandscape { - bool landscape = NO; - - //UIDeviceOrientation currentOrientation = [[UIDevice currentDevice] orientation]; - //if (UIInterfaceOrientationIsLandscape(currentOrientation)) { - // landscape = YES; - //} - // the above code cannot detect correctly if pad/phone lying flat, so we check the status bar orientation - UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; - switch (orientation) { - case UIInterfaceOrientationPortrait: - case UIInterfaceOrientationPortraitUpsideDown: - landscape = NO; - break; - case UIInterfaceOrientationLandscapeLeft: - case UIInterfaceOrientationLandscapeRight: - landscape = YES; - break; - default: - landscape = YES; - break; - } - - return landscape; -} - -#pragma mark - -#pragma ADBannerViewDelegate - -- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave -{ - NSLog(@"Banner view begining action"); - - [self writeJavascript:@"cordova.fireDocumentEvent('onClickAd');"]; - if (!willLeave) { - - } - return YES; -} - -- (void)bannerViewActionDidFinish:(ADBannerView *)banner -{ - NSLog(@"Banner view finished action"); -} - -- (void)bannerViewDidLoadAd:(ADBannerView *)banner -{ - NSLog(@"Banner Ad loaded"); - - Class adBannerViewClass = NSClassFromString(@"ADBannerView"); - if (adBannerViewClass) { - if (!self.bannerIsVisible) { - [self __showAd:YES]; - } - - [self writeJavascript:@"cordova.fireDocumentEvent('onReceiveAd');"]; - } -} - -- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError*)error -{ - NSLog(@"Banner failed to load Ad"); - - Class adBannerViewClass = NSClassFromString(@"ADBannerView"); - if (adBannerViewClass) { - //if ( self.bannerIsVisible ) { - // [self __showAd:NO]; - //} - - NSString *jsString = - @"cordova.fireDocumentEvent('onFailedToReceiveAd'," - @"{ 'error': '%@' });"; - [self writeJavascript:[NSString stringWithFormat:jsString, [error description]]]; - } -} - -- (void)deviceOrientationChange:(NSNotification *)notification{ - Class adBannerViewClass = NSClassFromString(@"ADBannerView"); - if (adBannerViewClass && self.bannerView) { - - CGRect superViewFrame = self.webView.superview.frame; - if([self __isLandscape]) { - superViewFrame.size.width = self.webView.superview.frame.size.height; - superViewFrame.size.height = self.webView.superview.frame.size.width; - } - - CGRect adViewFrameNew = self.bannerView.frame; - adViewFrameNew.size = [self.bannerView sizeThatFits:superViewFrame.size]; - self.bannerView.frame = adViewFrameNew; - - [self resizeViews]; - } -} - -- (void)dealloc { - [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; - [[NSNotificationCenter defaultCenter] - removeObserver:self - name:UIDeviceOrientationDidChangeNotification - object:nil]; - - self.bannerView.delegate = nil; - self.bannerView = nil; -} - -@end diff --git a/platforms/ios/TDA-Planner/config.xml b/platforms/ios/TDA-Planner/config.xml index 9bf176d..2e8a7eb 100644 --- a/platforms/ios/TDA-Planner/config.xml +++ b/platforms/ios/TDA-Planner/config.xml @@ -19,9 +19,6 @@ - - - diff --git a/platforms/ios/www/cordova_plugins.js b/platforms/ios/www/cordova_plugins.js index 51c1a0f..266959e 100644 --- a/platforms/ios/www/cordova_plugins.js +++ b/platforms/ios/www/cordova_plugins.js @@ -1,12 +1,5 @@ cordova.define('cordova/plugin_list', function(require, exports, module) { module.exports = [ - { - "file": "plugins/com.rjfun.cordova.plugin.iad/www/iAd.js", - "id": "com.rjfun.cordova.plugin.iad.iAd", - "clobbers": [ - "window.plugins.iAd" - ] - }, { "file": "plugins/org.apache.cordova.statusbar/www/statusbar.js", "id": "org.apache.cordova.statusbar.statusbar", @@ -18,7 +11,6 @@ module.exports = [ module.exports.metadata = // TOP OF METADATA { - "com.rjfun.cordova.plugin.iad": "0.1.2", "org.apache.cordova.statusbar": "0.1.7-dev" } // BOTTOM OF METADATA diff --git a/plugins/com.rjfun.cordova.plugin.iad/.fetch.json b/plugins/com.rjfun.cordova.plugin.iad/.fetch.json deleted file mode 100644 index 899ff01..0000000 --- a/plugins/com.rjfun.cordova.plugin.iad/.fetch.json +++ /dev/null @@ -1 +0,0 @@ -{"source":{"type":"git","url":"https://github.com/floatinghotpot/cordova-plugin-iad.git","subdir":"."}} \ No newline at end of file diff --git a/plugins/com.rjfun.cordova.plugin.iad/LICENSE b/plugins/com.rjfun.cordova.plugin.iad/LICENSE deleted file mode 100644 index 723f621..0000000 --- a/plugins/com.rjfun.cordova.plugin.iad/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2013 Liming Xie - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/plugins/com.rjfun.cordova.plugin.iad/README.md b/plugins/com.rjfun.cordova.plugin.iad/README.md deleted file mode 100644 index 6a9c199..0000000 --- a/plugins/com.rjfun.cordova.plugin.iad/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# Cordova iAd Plugin # - -## How to use ## - -Use Cordova/Phonegap command line tool: - - cordova create testiad com.rjfun.testiAd testiAd - cd testiad - cordova platform add ios - cordova plugin add https://github.com/floatinghotpot/cordova-plugin-iad.git - ... - -## Weak Linking the iAd Framework ## - -1. In your project, under "Targets", double click on the Target item -2. Go to the "General" Tab, under "Linked Libraries" -3. For the iAd Framework, change the value from "Required" to "Weak" - -## How to use it in javascript ## - - document.addEventListener("deviceready", onDeviceReady, false); - - document.addEventListener("onClickAd", onClickAd, false); - document.addEventListener("onReceiveAd", onReceiveAd, false); - document.addEventListener("onFailedToReceiveAd", onFailedToReceiveAd, false); - - function onDeviceReady() { - if ( window.plugins && window.plugins.iAd ) { - window.plugins.iAd.createBannerView( - { - 'bannerAtTop': true - }, function() { - window.plugins.iAd.showAd( true ); - }, function(){ - alert( "failed to create ad view" ); - }); - } else { - alert('iAd plugin not available/ready.'); - } - } - function onClickAd() { - // count click - } - function onReceiveAd() { - // do whatever you want - } - function onFailedToReceiveAd( ret ) { - alert( ret.error ); - } - -## Related ## - -It's for iOS only. If you are writing App for Android/iOS, may try this cordova plugin: - - https://github.com/floatinghotpot/cordova-plugin-admob.git - - diff --git a/plugins/com.rjfun.cordova.plugin.iad/plugin.xml b/plugins/com.rjfun.cordova.plugin.iad/plugin.xml deleted file mode 100644 index 987fc70..0000000 --- a/plugins/com.rjfun.cordova.plugin.iad/plugin.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - iAd - Apple iAd support (iOS only) - Liming Xie - MIT - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/com.rjfun.cordova.plugin.iad/src/ios/CDViAd.h b/plugins/com.rjfun.cordova.plugin.iad/src/ios/CDViAd.h deleted file mode 100644 index af83c07..0000000 --- a/plugins/com.rjfun.cordova.plugin.iad/src/ios/CDViAd.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// CDViAd.h -// iAd Plugin for PhoneGap/Cordova -// -// Created by shazron on 10-07-12. -// Copyright 2010 Shazron Abdullah. All rights reserved. -// Cordova v1.5.0 Support added 2012 @RandyMcMillan -// - -#import -#import -#import - -@interface CDViAd : CDVPlugin { - -} - -@property (nonatomic, retain) ADBannerView* bannerView; -@property (assign) BOOL bannerIsVisible; -@property (assign) BOOL bannerIsInitialized; -@property (assign) BOOL bannerAtTop; - -- (void) createBannerView:(CDVInvokedUrlCommand *)command; -- (void) showAd:(CDVInvokedUrlCommand *)command; - -@end diff --git a/plugins/com.rjfun.cordova.plugin.iad/src/ios/CDViAd.m b/plugins/com.rjfun.cordova.plugin.iad/src/ios/CDViAd.m deleted file mode 100644 index da73df3..0000000 --- a/plugins/com.rjfun.cordova.plugin.iad/src/ios/CDViAd.m +++ /dev/null @@ -1,348 +0,0 @@ -// -// CDViAd.m -// Ad Plugin for PhoneGap -// -// Created by shazron on 10-07-12. -// Copyright 2010 Shazron Abdullah. All rights reserved. -// Cordova v1.5.0 Support added 2012 @RandyMcMillan -// Cordova v3.0.0 Support added 2013 @LimingXie - -#import "CDViAd.h" -#import -#import "MainViewController.h" - -@interface CDViAd() - -- (void) __prepare:(BOOL)atTop; -- (void) __showAd:(BOOL)show; -- (bool) __isLandscape; - -@end - - -@implementation CDViAd - -@synthesize bannerView; -@synthesize bannerIsVisible, bannerIsInitialized, bannerAtTop; - -#pragma mark - -#pragma mark Public Methods - -- (CDVPlugin *)initWithWebView:(UIWebView *)theWebView { - self = (CDViAd *)[super initWithWebView:theWebView]; - if (self) { - // These notifications are required for re-placing the ad on orientation - // changes. Start listening for notifications here since we need to - // translate the Smart Banner constants according to the orientation. - [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(deviceOrientationChange:) - name:UIDeviceOrientationDidChangeNotification - object:nil]; - } - return self; -} - -- (void) createBannerView:(CDVInvokedUrlCommand *)command -{ - CDVPluginResult *pluginResult; - NSString *callbackId = command.callbackId; - NSArray* arguments = command.arguments; - - NSUInteger argc = [arguments count]; - if (argc > 1) { - return; - } - - BOOL atTop = NO; - NSString* atTopValue = [arguments objectAtIndex:0]; - if( atTopValue ) atTop = [atTopValue boolValue]; - [self __prepare:atTop]; - - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; - [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; -} - -- (void) showAd:(CDVInvokedUrlCommand *)command -{ - CDVPluginResult *pluginResult; - NSString *callbackId = command.callbackId; - NSArray* arguments = command.arguments; - - NSUInteger argc = [arguments count]; - if (argc > 1) { - return; - } - - BOOL show = YES; - NSString* showValue = [arguments objectAtIndex:0]; - if( showValue ) show = [showValue boolValue]; - [self __showAd:show]; - - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; - [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; -} - -- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration -{ - Class adBannerViewClass = NSClassFromString(@"ADBannerView"); - if (adBannerViewClass && self.bannerView) { - - CGRect superViewFrame = self.webView.superview.frame; - if([self __isLandscape]) { - superViewFrame.size.width = self.webView.superview.frame.size.height; - superViewFrame.size.height = self.webView.superview.frame.size.width; - } - - CGRect adViewFrameNew = self.bannerView.frame; - adViewFrameNew.size = [self.bannerView sizeThatFits:superViewFrame.size]; - self.bannerView.frame = adViewFrameNew; - - [self resizeViews]; - } -} - -- (void) resizeViews -{ - Class adBannerViewClass = NSClassFromString(@"ADBannerView"); - if (adBannerViewClass && self.bannerView) { - - // If the ad is not showing or the ad is hidden, we don't want to resize anything. - BOOL adIsShowing = [self.webView.superview.subviews containsObject:self.bannerView] && - (! self.bannerView.hidden); - - // Handle changing Smart Banner constants for the user. - bool isLandscape = [self __isLandscape]; - - // iOS7 Hack, handle the Statusbar - MainViewController *mainView = (MainViewController*) self.webView.superview.window.rootViewController; - BOOL isIOS7 = ([[UIDevice currentDevice].systemVersion floatValue] >= 7); - CGFloat top = isIOS7 ? mainView.topLayoutGuide.length : 0.0; - - // Frame of the main container view that holds the Cordova webview. - CGRect superViewFrame = self.webView.superview.frame; - // Frame of the main Cordova webview. - CGRect webViewFrame = self.webView.frame; - CGRect bannerViewFrame = self.bannerView.frame; - - // Let's calculate the new position and size - CGRect superViewFrameNew = superViewFrame; - CGRect webViewFrameNew = webViewFrame; - CGRect bannerViewFrameNew = bannerViewFrame; - - if( isLandscape ) { - superViewFrameNew.size.width = superViewFrame.size.height; - superViewFrameNew.size.height = superViewFrame.size.width; - } - - if(adIsShowing) { - if(self.bannerAtTop) { - // move banner view to top - bannerViewFrameNew.origin.y = top; - // move the web view to below - webViewFrameNew.origin.y = top + bannerViewFrame.size.height; - } else { - // move web view to top - webViewFrameNew.origin.y = top; - // move the banner view to below - bannerViewFrameNew.origin.y = superViewFrameNew.size.height - bannerViewFrame.size.height; - } - - webViewFrameNew.size.width = superViewFrameNew.size.width; - webViewFrameNew.size.height = superViewFrameNew.size.height - bannerViewFrame.size.height - top; - - bannerViewFrameNew.origin.x = (superViewFrameNew.size.width - bannerViewFrameNew.size.width) * 0.5f; - - NSLog(@"webview: %d x %d, banner view: %d x %d", - (int) webViewFrameNew.size.width, (int) webViewFrameNew.size.height, - (int) bannerViewFrameNew.size.width, (int) bannerViewFrameNew.size.height ); - - self.bannerView.frame = bannerViewFrameNew; - - } else { - webViewFrameNew = superViewFrameNew; - webViewFrameNew.origin.y += top; - webViewFrameNew.size.height -= top; - - NSLog(@"webview: %d x %d", - (int) webViewFrameNew.size.width, (int) webViewFrameNew.size.height ); - - } - - self.webView.frame = webViewFrameNew; - } -} - -#pragma mark - -#pragma mark Private Methods - -- (void) __prepare:(BOOL)atTop -{ - NSLog(@"CDViAd Prepare Ad, bannerAtTop: %d", atTop); - - Class adBannerViewClass = NSClassFromString(@"ADBannerView"); - if (adBannerViewClass && !self.bannerView) { - self.bannerView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)]; - - CGRect superViewFrame = self.webView.superview.frame; - if([self __isLandscape]) { - superViewFrame.size.width = self.webView.superview.frame.size.height; - superViewFrame.size.height = self.webView.superview.frame.size.width; - } - - CGRect adViewFrameNew = self.bannerView.frame; - adViewFrameNew.size = [self.bannerView sizeThatFits:superViewFrame.size]; - self.bannerView.frame = adViewFrameNew; - - NSLog(@"x,y,w,h = %d,%d,%d,%d", - (int) adViewFrameNew.origin.x, (int) adViewFrameNew.origin.y, - (int) adViewFrameNew.size.width, (int) adViewFrameNew.size.height ); - - self.bannerView.delegate = self; - - self.bannerAtTop = atTop; - self.bannerIsVisible = NO; - self.bannerIsInitialized = YES; - - [self resizeViews]; - } -} - -- (void) __showAd:(BOOL)show -{ - NSLog(@"CDViAd Show Ad: %d", show); - - if (!self.bannerIsInitialized){ - [self __prepare:NO]; - } - - if (!(NSClassFromString(@"ADBannerView") && self.bannerView)) { // ad classes not available - return; - } - - if (show == self.bannerIsVisible) { // same state, nothing to do - if( self.bannerIsVisible) { - [self resizeViews]; - } - } else if (show) { - [[[super webView] superview] addSubview:self.bannerView]; - [[[super webView] superview] bringSubviewToFront:self.bannerView]; - [self resizeViews]; - - self.bannerIsVisible = YES; - } else { - [self.bannerView removeFromSuperview]; - [self resizeViews]; - - self.bannerIsVisible = NO; - } - -} - -- (bool)__isLandscape { - bool landscape = NO; - - //UIDeviceOrientation currentOrientation = [[UIDevice currentDevice] orientation]; - //if (UIInterfaceOrientationIsLandscape(currentOrientation)) { - // landscape = YES; - //} - // the above code cannot detect correctly if pad/phone lying flat, so we check the status bar orientation - UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; - switch (orientation) { - case UIInterfaceOrientationPortrait: - case UIInterfaceOrientationPortraitUpsideDown: - landscape = NO; - break; - case UIInterfaceOrientationLandscapeLeft: - case UIInterfaceOrientationLandscapeRight: - landscape = YES; - break; - default: - landscape = YES; - break; - } - - return landscape; -} - -#pragma mark - -#pragma ADBannerViewDelegate - -- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave -{ - NSLog(@"Banner view begining action"); - - [self writeJavascript:@"cordova.fireDocumentEvent('onClickAd');"]; - if (!willLeave) { - - } - return YES; -} - -- (void)bannerViewActionDidFinish:(ADBannerView *)banner -{ - NSLog(@"Banner view finished action"); -} - -- (void)bannerViewDidLoadAd:(ADBannerView *)banner -{ - NSLog(@"Banner Ad loaded"); - - Class adBannerViewClass = NSClassFromString(@"ADBannerView"); - if (adBannerViewClass) { - if (!self.bannerIsVisible) { - [self __showAd:YES]; - } - - [self writeJavascript:@"cordova.fireDocumentEvent('onReceiveAd');"]; - } -} - -- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError*)error -{ - NSLog(@"Banner failed to load Ad"); - - Class adBannerViewClass = NSClassFromString(@"ADBannerView"); - if (adBannerViewClass) { - //if ( self.bannerIsVisible ) { - // [self __showAd:NO]; - //} - - NSString *jsString = - @"cordova.fireDocumentEvent('onFailedToReceiveAd'," - @"{ 'error': '%@' });"; - [self writeJavascript:[NSString stringWithFormat:jsString, [error description]]]; - } -} - -- (void)deviceOrientationChange:(NSNotification *)notification{ - Class adBannerViewClass = NSClassFromString(@"ADBannerView"); - if (adBannerViewClass && self.bannerView) { - - CGRect superViewFrame = self.webView.superview.frame; - if([self __isLandscape]) { - superViewFrame.size.width = self.webView.superview.frame.size.height; - superViewFrame.size.height = self.webView.superview.frame.size.width; - } - - CGRect adViewFrameNew = self.bannerView.frame; - adViewFrameNew.size = [self.bannerView sizeThatFits:superViewFrame.size]; - self.bannerView.frame = adViewFrameNew; - - [self resizeViews]; - } -} - -- (void)dealloc { - [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; - [[NSNotificationCenter defaultCenter] - removeObserver:self - name:UIDeviceOrientationDidChangeNotification - object:nil]; - - self.bannerView.delegate = nil; - self.bannerView = nil; -} - -@end diff --git a/plugins/com.rjfun.cordova.plugin.iad/test/index.html b/plugins/com.rjfun.cordova.plugin.iad/test/index.html deleted file mode 100644 index c8452f2..0000000 --- a/plugins/com.rjfun.cordova.plugin.iad/test/index.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - Hello World - - - - - -
-
width * height
-

-

-
- - diff --git a/plugins/com.rjfun.cordova.plugin.iad/www/iAd.js b/plugins/com.rjfun.cordova.plugin.iad/www/iAd.js deleted file mode 100644 index fe7eac0..0000000 --- a/plugins/com.rjfun.cordova.plugin.iad/www/iAd.js +++ /dev/null @@ -1,38 +0,0 @@ -var argscheck = require('cordova/argscheck'), exec = require('cordova/exec'); - -iAdExport = {}; - -iAdExport.createBannerView = function(options, successCallback, failureCallback) { - var defaults = { - 'bannerAtTop' : false - }; - - // Merge optional settings into defaults. - for ( var key in defaults) { - if (typeof options[key] !== 'undefined') { - defaults[key] = options[key]; - } - } - cordova.exec(successCallback, - failureCallback, - 'iAd', - 'createBannerView', - [ defaults['bannerAtTop'] ] - ); -}; - -iAdExport.showAd = function( show, successCallback, failureCallback) { - if (show === undefined) { - show = true; - } - - cordova.exec( - successCallback, - failureCallback, - 'iAd', - 'showAd', - [ show ] - ); -}; - -module.exports = iAdExport; diff --git a/plugins/ios.json b/plugins/ios.json index 171d309..734abed 100644 --- a/plugins/ios.json +++ b/plugins/ios.json @@ -7,27 +7,13 @@ "files": { "framework": { "parents": { - "AdSupport.framework": [ - { - "xml": "false", - "count": 1 - } - ], - "iAd.framework": [ - { - "xml": "true", - "count": 1 - } - ] + "AdSupport.framework": [], + "iAd.framework": [] } }, "config.xml": { "parents": { "/*": [ - { - "xml": "", - "count": 1 - }, { "xml": "", "count": 1 @@ -50,9 +36,6 @@ } }, "installed_plugins": { - "com.rjfun.cordova.plugin.iad": { - "PACKAGE_NAME": "com.georgegarside.tdaplanner" - }, "org.apache.cordova.statusbar": { "PACKAGE_NAME": "com.georgegarside.tdaplanner" } diff --git a/www/index.html b/www/index.html index e83c23a..16e1a3d 100644 --- a/www/index.html +++ b/www/index.html @@ -21,30 +21,11 @@