Add iAD on your app

by Deepak Dhakal 29. February 2012 11:39

Here is a step by step as I did it.

1. You need to enable iAd Network in your ituneconnect account :-
a) Make sure your iAd Contract is in effect.
b) Add a new app or if you are adding iAd to existing app, click on add version.
Then on that version, Enable the iAd for that app.
c) You may need to wait a while, then when you go to your iTunesconnect home page, you will see a new module "iAd Network" on the right column. Click that and follow the instructions.

2. Then just go to your XCode, add iAds thingies:-
a) Add Existing Framework - > iAd.framework.
b) In your .h add #import <iAd/iAd.h>
c) In your .h, add <ADBannerViewDelegate>
d) Create IBOutlet for the ADBannerView, drop the iAd object in your IB and
link it to the IBOutlet
e) Put all of the 4 delegates in your code. You need to show the ADBanner when an ad is called by the delegate. And when the delegate says there are no ads or error (due to no internet connection), you need to hide the AD.

This is my code:

Code:
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave {
	return YES;
	
}


- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
	AdIsShowing = YES;
	if (myAD.center.y>500) {
		[self moveAdIn]; // this is a custom method to show ad and move things around.
	}
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
	AdIsShowing = NO;
	if (myAD.center.y<460) {
	[self moveAdOut]; // this is a custom method to show ad and move things around.
	}
	
}


-(void)bannerViewActionDidFinish:(ADBannerView *)banner
{
}

Done. When you run, you should see the iAd Test Advertisment.

 

There is youtube video that explains in detail as well.

http://www.youtube.com/watch?v=cM9DqJmj45g

Tags: , ,

iPhone

Stock Web site

by Deepak Dhakal 19. February 2012 09:29

Tags:

Stock

Two namespaces and similar class name inside in C#

by Deepak Dhakal 7. February 2012 13:04
I have namaspace for two version of the same class, V1 and v2
namespace Hello.ThisIsAnExample.Noway.StillAnExample.V1
{
Class A
{
public void Nothing()
{
}
}
}

namespace Hello.ThisIsAnExample.Noway.StillAnExample.V2
{
Class A
{
public void Nothing()
{
}
}
}


Then in the Main class, use like this

using V1=Hello.ThisIsAnExample.Noway.StillAnExample.V1
using V2=Hello.ThisIsAnExample.Noway.StillAnExample.V2

Pubic Main()
{
 V1.A.Nothing(); // Calls V1
 V2.A.Nothing(); // Calls V2
}



Sweet !!! is not it ???

Tags:

.Net

Prevent iphone going to sleep mode

by Deepak Dhakal 30. January 2012 07:17

use one line of code

[UIApplication sharedApplication].idleTimerDisabled=YES'

Note: This will leave the screen's background light on, (after the user pressed the sleep button,) which will drain the battery.

Tags:

xml serialization in .Net with datetime

by Deepak Dhakal 8. December 2011 11:22

If you have

<xs:element name="start" type="xs:date"/>

make sure you parse as

<start>2002-09-24</start>

 

or if you have

<xs:element name="startdate" type="xs:dateTime"/>

 

you parse as

<startdate>2002-05-30T09:30:10.5</startdate>

 

if you don't then you will get error like

at System.DateTimeParse.ParseExactMultiple(String s, String[ formats, DateTimeFormatInfo dtfi, DateTimeStyles style)
at System.DateTime.ParseExact(String s, String[ formats, IFormatProvider provider, DateTimeStyles style)
at System.Data.SQLite.SQLiteConvert.ToDateTime(String dateText)
at System.Data.SQLite.SQLiteConvert.ToDateTime(IntPtr ptr, Int32 len)
at System.Data.SQLite.SQLite3.GetDateTime(SQLiteStatement stmt, Int32 index)
at System.Data.SQLite.SQLite3.GetValue(SQLiteStatement stmt, Int32 index, SQLiteType typ)
at System.Data.SQLite.SQLiteDataReader.GetValue(Int32 i)
at System.Data.SQLite.SQLiteDataReader.GetValues(Object[ values)
at System.Data.ProviderBase.DataReaderContainer.CommonLanguageSubsetDataReader.GetValues(Object[ values)
at System.Data.ProviderBase.SchemaMapping.LoadDataRow()br /> at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DataAdapter.Fill(DataTable[ dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[ datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[ dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at WindowsFormsApplication2.AssetManagerDBDataSetTableAdapters.AssetsTableAdapter.Fill(AssetsDataTable dataTable) in C:\Users\Administrator\Desktop\SQLite Version\WiscoAssetImporter\AssetManagerDBDataSet1.Designer.cs:line 4408
at WindowsFormsApplication2.FormMerge.FormAnalyse_Load(Object sender, EventArgs e) in C:\Users\Administrator\Desktop\SQLite Version\WiscoAssetImporter\FormMerge.cs:line 71

Tags:

Add Archos on your Device list in Eclipse for Android Development

by Deepak Dhakal 1. October 2011 19:22

Archos support proposes a solution to the bug on ADB connection mode with Mac OSX 10.6.2 with firmwares updates since 1.4.07 to the latest 1.4.16 :

You actually need to modify or create the adb_usb.ini file

In terminal, you need to type :
echo "0x0e79" >~/.android/adb_usb.ini
Then
./adb kill-server
and
./adb start-server


I just modify the first command in order to preserve the original contents of the ~/.android/adb_usb.ini file by issuing the following command
echo "0x0e79" >> ~/.android/adb_usb.ini


Here is the result :

$ adb devices
List of devices attached

$ adb devices
List of devices attached

$ more ~/.android/adb_usb.ini
# ANDROID 3RD PARTY USB VENDOR ID LIST -- DO NOT EDIT.
# USE 'android update adb' TO GENERATE.
# 1 USB VENDOR ID PER LINE.
$ echo "0x0e79" >> ~/.android/adb_usb.ini
$ more ~/.android/adb_usb.ini
# ANDROID 3RD PARTY USB VENDOR ID LIST -- DO NOT EDIT.
# USE 'android update adb' TO GENERATE.
# 1 USB VENDOR ID PER LINE.
0x0e79
$ adb kill-server
$ adb start-server
$ adb devices
List of devices attached
A5S-xxxx0004-xxxx0000-0403xxxx-1500xxxx device

Tags:

Powered by BlogEngine.NET 1.5.0.7 - Old School Theme by n3o Web Designers