. Net platform pushes ios messages and. net platform ios messages
1. messages can be pushed to customers in ios apps.
2. You need an apple certificate and password (how to obtain it, search for it online, and you need to pay the fee)
3. the ios app is installed on the iphone.
4. Reference PushSharp. Apple. dll and PushSharp. Core. dll in the. net Project (these two files are searched online and have source code)
5. Start to write the code and define the global object PushBroker pusher = new PushBroker ();
6. Registration Method
Protected void startApp () {pusher. registerAppleService (new ApplePushChannelSettings (File. readAllBytes (CertificatePath), CertificatePassword); pusher. onDeviceSubscriptionChanged + = pusher_OnDeviceSubscriptionChanged; pusher. onDeviceSubscriptionExpired + = pusher_OnDeviceSubscriptionExpired; pusher. onicationicationsent + = pusher_OnNotificationSent; pusher. onicationfafailed + = pusher_OnNotificationFailed;} static void pusher_OnNotificationFailed (object sender, INotification notification, Exception error) {var n = (AppleNotification) notification; // error. message... get push error information Log. error ("Push error message", Error);} static void pusher_OnNotificationSent (object sender, INotification notification) {// var n = (AppleNotification) notification after successful message push; // n. payload. alert. body to get the pushed message content... log. error ("push content" + n. payload. alert. body);} static void upload (object sender, string expiredSubscriptionId, DateTime expirationDateUtc, INotification notification) {// Delete expired expiredSubscriptionId} static void upload (object sender, string oldSubscriptionId, string newSubscriptionId, INotification notification) {// update the oldSubscriptionId in the database to newSubscriptionId}
The startApp () method has two parameters,
CertificatePath: Certificate path
CertificatePassword: Password 7, push code
Pusher. queueNotification (new AppleNotification (). forDeviceToken (TokenID ). withAlert ("Pushed content "). withBadge (1 ). withSound ("default"); // obtain the device's TokenID from the database or other places. Each iphone has a TokenID
8. After you have prepared these items, you can test them. I personally pass the test. If you have any questions, leave a message to help you!
9. If you want to push data on Android devices, the project will introduce PushSharp. Android. dll. The Code will be updated later. Stay tuned to you!
10, Source Code address: http://pan.baidu.com/s/1pJoD8IR
How to push ios information on the net Platform
Source: Online
1. messages can be pushed to customers in ios apps.
2. You need an apple certificate and password (how to obtain it, search for it online, and you need to pay the fee)
3. the ios app is installed on the iphone.
4. Reference PushSharp. Apple. dll and PushSharp. Core. dll in the. net Project (these two files are searched online and have source code)
5. Start to write the code and define the global object PushBroker pusher = new PushBroker ();
6. Registration Method
Copy code
Protected void startApp ()
{
Pusher. RegisterAppleService (new
ApplePushChannelSettings (File. ReadAllBytes (CertificatePath ),
CertificatePassword ));
Pusher. OnDeviceSubscriptionChanged + =
Pusher_OnDeviceSubscriptionChanged;
Pusher. OnDeviceSubscriptionExpired + =
Pusher_OnDeviceSubscriptionExpired;
Pusher. OnNotificationSent + =
Pusher_OnNotificationSent;
Pusher. OnNotificationFailed + =
Pusher_OnNotificationFailed;
}
Static void pusher_OnNotificationFailed (object sender, inoication ication
Notification, Exception error)
{
Var n = (AppleNotification) notification;
// Error. Message... get push error information
Log. Error ("Push error message", Error );
}
Static void pusher_OnNotificationSent (object sender, INotification
Notification)
{
// After the message is pushed successfully
Var n = (AppleNotification) notification;
// N. Payload. Alert. Body get the pushed message content...
Log. Error ("push content" + n. Payload. Alert. Body );
}
Static void pusher_OnDeviceSubscriptionExpired (object sender,
String expiredSubscriptionId, DateTime expirationDateUtc, INotification
Notification)
{
... The remaining full text>
NET push for IOS push, "SSPI call failed, see internal exception"
Breakpoint to see what is displayed in the InnerException of Exception