如何以xamarin形式获取android和IOS设备令牌?

时间:2017-09-07 21:29:10

标签: android xamarin push-notification xamarin.forms token

我需要两个令牌......我正在使用PushNotification插件...我知道它返回令牌......但我认为文档非常糟糕......我不需要显示通知......我只需要令牌......只有它 谁能救我?我真的需要它。我需要在app开发人员中进行一些配置吗? 我已经获得了android的发送者ID,我在两者中初始化了插件:AppDelegate和MainActivity 帮助PLEEEAAAAAAAAS

我的课程在pcl

using PushNotification.Plugin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using PushNotification.Plugin.Abstractions;

namespace neoFly_Montana
{
public class PushNot : IPushNotificationListener
{
    public void OnError(string message, DeviceType deviceType)
    {
        throw new NotImplementedException();
    }

    public void OnMessage(JObject values, DeviceType deviceType)
    {
        throw new NotImplementedException(); 
    }

    public void OnRegistered(string token, DeviceType deviceType)
    {
        throw new NotImplementedException();
    }

    public void OnUnregistered(DeviceType deviceType)
    {
        throw new NotImplementedException();
    }

    public bool ShouldShowNotification()
    {
        throw new NotImplementedException();
    }
}
}

1 个答案:

答案 0 :(得分:1)

一旦设备已在APNS或GCM / FCM注册,Google和Apple都会以OnRegistered方式向您发送令牌。

OnRegistered中,您可以添加逻辑来保存令牌。

public void OnRegistered(string token, DeviceType deviceType)
{
    //use token here
}
相关问题