public static ResultPush Ios(IosMessage iosMessage)
        {
            ResultPush       resultPush  = new ResultPush();
            X509Certificate2 certificate = new X509Certificate2(File.ReadAllBytes(GetConfig.Certificate.IOS), GetConfig.Certificate.IOSPassword);

            var        appleCert = File.ReadAllBytes(GetConfig.Certificate.IOS);
            PushBroker push      = Pusher(resultPush);

            push.RegisterAppleService(new ApplePushChannelSettings(false, certificate));

            AppleNotificationPayload appleNotificationPayload = new AppleNotificationPayload(iosMessage.Alert, iosMessage.Badge.Value, iosMessage.Sound.ToString());

            var appleNotification = new AppleNotification()
                                    .ForDeviceToken(iosMessage.DeviceToken)
                                    .WithPayload(appleNotificationPayload);


            if (iosMessage.Sound.HasValue)
            {
                appleNotification.WithSound(iosMessage.Sound.ToString());
            }

            if (iosMessage.Badge.HasValue)
            {
                appleNotification.WithBadge(iosMessage.Badge.Value);
            }

            push.QueueNotification(appleNotification);

            return(resultPush);
        }
示例#2
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         DestroyObject(gameObject);
     }
     DontDestroyOnLoad(gameObject);
 }
示例#3
0
 public IosMessagePush(IosMessage iosMessage)
 {
     this.badge = iosMessage.Badge;
     this.alert = iosMessage.Alert;
     this.sound = iosMessage.Sound;
 }