Unity3d is written on IOS (push notification)

Source: Internet
Author: User
Tags openssl x509


article Songyang

This article is from the Asura road , prohibited for commercial purposes, reproduced please indicate the source.  

http://blog.csdn.net/fansongy/article/details/ 43954515


/span>

/p>





Configuring certificates

Just follow this to generate a lot of certificates http://www.cnblogs.com/gpwzw/archive/2012/03/31/apple_push_notification_services_tutorial_part_1-2.html

There are some errors entered in the command, you can refer to Http://www.tuicool.com/articles/vy2MbmZ

OpenSSL x509-in aps_development.cer-inform der-out pushchatcert.pemopenssl pkcs12-nocerts-out pushchatkey.pem-in Pus Hchatkey.p12cat Pushchatcert.pem Pushchatkey.pem > Ck.pem

After the certificate is configured, the UnityAppController.mm function in the didFinishLaunchingWithOptions add:

    #if __iphone_os_version_max_allowed >= 80000 if ([Application respondstoselector: @selector (registerusernotif Icationsettings:)] {//Use Registerusernotificationsettings [application registerusernotifications Ettings:[uiusernotificationsettings settingsfortypes: (Uiusernotificationtypesound | Uiusernotificationtypealert |                        Uiusernotificationtypebadge) Categories:nil];        [Application registerforremotenotifications];             } else {//use Registerforremotenotifications [application registerforremotenotificationtypes: (Uiremotenotificationtypebadge | Uiremotenotificationtypealert |        Uiremotenotificationtypesound)]; } #else//Use Registerforremotenotifications [application registerforremotenotificationtypes: (U Iremotenotificationtypebadge | Uiremotenotificationtypealert |    Uiremotenotificationtypesound)]; #endif

This completes the configuration of the registration, for the unity3d of the registration, should be incompatible with the IOS8 system

function Start () {Notificationservices.registerforremotenotificationtypes (Remotenotificationtype.alert | Remotenotificationtype.badge | Remotenotificationtype.sound);} function Update () {if (!tokensent) {var token:byte[] = notificationservices.devicetoken;if (token! = null) {//Send Tok En to a providervar hextoken:string = "%" + System.BitConverter.ToString (token). Replace ('-', '% '); new WWW ("http://" +address+ "/?token=" +hextoken); tokensent = True;}}}

If you use Unity3d, you can add the Didregisterforremotenotificationswithdevicetoken function to the

NSString *tokenstr = [[Devicetoken description] Stringbytrimmingcharactersinset:[nscharacterset charactersetwithcharactersinstring:@ "<>"]];tokenstr = [tokenstr stringbyreplacingoccurrencesofstring:@ "" withstring:@ ""]; Unitysendmessage ("Bridge", "Onpushid", tokenstr.utf8string), and it is also impractical to use update to handle tokens.

After the token succeeds, change the didRegisterForRemoteNotificationsWithDeviceToken function, add a message back to Unity3d, and send the result to the server. I think we can use a single example, the whole set of things to abstract out, back to have the effort to clean up.

If you think this article is helpful to you, you can take a Top , not only do not want to be a father, but also let more people can see it ...

Unity3d is written on IOS (push notification)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.