Joh*_*n D 6 xamarin.ios apple-push-notifications apns-sharp
我正在使用Monotouch for mac并且已经完成了检索配置文件证书的步骤,该证书在此过程中启用了推送通知.我有一个工作的应用程序,我现在正在尝试使用apns-sharp和moon-apns,但无法弄清楚如何检索我的设备令牌.我希望有人可以为我提供详细而直接的步骤来实现这一目标.
在您的FinishedLaunching方法中,通过UIApplication您获得的对象注册该应用程序以进行远程通知:
// Pass the UIRemoteNotificationType combinations you want
app.RegisterForRemoteNotificationTypes(UIRemoteNotificationType.Alert |
UIRemoteNotificationType.Sound);
Run Code Online (Sandbox Code Playgroud)
然后,在您的AppDelegate类中,重写RegisteredForRemoteNotifications方法:
public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken)
{
// The device token
byte[] token = deviceToken.ToArray();
}
Run Code Online (Sandbox Code Playgroud)
您还必须重写该FailedToRegisterForRemoteNotifications方法以处理错误(如果有):
public override void FailedToRegisterForRemoteNotifications (UIApplication application, NSError error)
{
// Do something with the error
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2958 次 |
| 最近记录: |