How can i implement apple Push Notification ?? [cl

2019-02-03 21:18发布

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.

2条回答
2楼-- · 2019-02-03 21:22
女痞
3楼-- · 2019-02-03 21:30

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.

查看更多
登录 后发表回答