What things needed to add APN in .NET server

≡放荡痞女 提交于 2020-01-14 06:35:48

问题


As i have serch on google i am not sure that what things needed to implement APN in .NET server. In PHP server we create .PEM file but my .NET developer ask me for .P12 file so i am confuse.

As this nice Tutorial from raywenderlich suggest what thing need to generate for PHP server which is .PEM file but what for .NET?

AS this tutorial suggest I have

  • The CSR (of developer certificate)
  • The private key as a p12 file (myapp.p12) (of development certificate)
  • The SSL certificate, aps_development.cer

And i want to send this app for adHoc distribution so Is my p12 file will be from distribution certificate?

Or is tht i have to just give .p12 file of my distribution certificate and ssl certificate?


回答1:


I think you have all the things you need.

You have aps_development.cer add it in your keyChain Access. Which will display like this...

After that export this certificate in .p12 file

Add the password if you want

And than mac will ask your user password to verify

After you Do all this thing you got .p12 file of your SSL certificate. Now add this code to your AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Let the device know we want to receive push notifications
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
        (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

    return YES;
}

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
    NSLog(@"Dilip My token is: %@", deviceToken);
       //remember this token it will be used at server side
}

- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
    NSLog(@"Dilip Failed to get token, error: %@", error);
}

Now you have two thing first is certificate.p12 file and Device Token give it to your .net developer and you are done at your side you will get notification.

At server side This two link is really helpful to implement APN at server side.

LINK 1 LINK 2

And yes don't forget the token you get from apple will display like this <a3002e43 c1d2d80d 95b0a1a6 893b3f7c c410a489 747b933d 04551d68 688c6c65> so you have to remove space and bracket that bcoz i have a problem when i have implemented APN first time bcoz of this space your string must be look like this a3002e43c1d2d80d95b0a1a6893b3f7cc410a489747b933d04551d68688c6c65.




回答2:


Alternatively, if you want a simple to-the-point solution and you don't mind using 3rd party software, you could take a look at PushSharp. This library is very popular and supports many customization options.

To generate the needed certificate and key, use this tutorial.

Hope it helps!



来源:https://stackoverflow.com/questions/17714948/what-things-needed-to-add-apn-in-net-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!