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)