Suraj Suraj - 1 year ago 102
Objective-C Question

How can i implement apple Push Notification ??

i am new in iphone development,i want to implement push Notification in my application. i have no idea about that. anyone give sample code.

Answer Source

Firstly, you have to either rent or own a server that is responsible for communicating with Apple's APNS servers. Yes, when pushing notifications to your app's users, your server has to first push it to Apple and have Apple transfer those notifications to specific users on your behalf.

And second, override and implement the following methods in your AppDelegate's .m file:

    - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {  
    - (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error {  
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    //You probably already implemented this one
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 

And test your code and your server with Apple's Sandbox server before you put your app into production.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download