2017-03-02 54 views
1

我有一個Xamarin Forms應用程序,我無法使推送通知在iOS中工作。他們在Android中工作正常。該設備正在使用SDK v4.1.0正式向Urban Airship註冊。我能夠獲得一個ChannelId和一個設備令牌。當我發送Dev信道時,Android設備會收到通知,但iOS設備不會。在Urban Airship中,Full Message Report顯示消息已發送到Android設備以及我已測試過的兩個iOS設備。我相信我錯過了一些小事,但我無法弄清楚它是什麼。以下是App Delegate的參考資料。從我見過的例子來看,這非常簡單。Xamarin Forms iOS設備不會收到來自Urban Airship的推送

using System; 
using System.Collections.Generic; 
using System.Linq; 

using Foundation; 
using UIKit; 
using UrbanAirship; 

namespace -----------.Mobile.iOS 
{ 
    [Register("AppDelegate")] 
    public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate 
    { 
     public override bool FinishedLaunching(UIApplication app, NSDictionary options) 
     { 
      global::Xamarin.Forms.Forms.Init(); 

      UAConfig config = new UrbanAirship.UAConfig(); 
      config.DevelopmentAppKey = "----------------------"; 
      config.DevelopmentAppSecret = "----------------------"; 
      config.ProductionAppKey = "----------------------"; 
      config.ProductionAppSecret = "----------------------"; 

#if DEBUG 
      config.InProduction = false; 
#else 
      config.InProduction = true 
#endif 
      UAirship.TakeOff(config); 
      UAirship.Push.UserPushNotificationsEnabled = true; 
      UAirship.Push.ChannelTagRegistrationEnabled = true; 

      // Write the ChannelId for reference later. 

      Guid urbanAirshipChannelId; 
      UrbanAirshipData uaData = new UrbanAirshipData(); 
      if (Guid.TryParse(UAirship.Push.ChannelID, out urbanAirshipChannelId)) 
      { 
       uaData.UrbanAirshipChannelId = urbanAirshipChannelId; 
       uaData.UrbanAirshipDeviceType = Common.Utilities.Enumerations.eUrbanAirshipDeviceType.iOS; 
      } 
      UAirship.Push.PushNotificationDelegate = PushReceived(); 


      LoadApplication(new App(uaData)); 

      return base.FinishedLaunching(app, options); 
     } 

     private UAPushNotificationDelegate PushReceived() 
     { 
      UAPushNotificationDelegate result = new UAPushNotificationDelegate(); 

      return result; 
     } 



    } 
} 

任何反饋或意見將不勝感激。

回答

0

UAirship.Push.PushNotificationDelegate = PushReceived(); ,有一個與城市飛艇代表一個問題,即他們不存儲的強引用委託 - https://github.com/urbanairship/xamarin-component/issues/40

但是,不會造成設備無法接收推。默認情況下,如果應用程序處於前臺,則在推送接收時不會發生任何事情。在後臺它會發布通知。您可以通過在iOS 10的UAPush實例上設置默認前景通知選項來修改該行爲。

如果您仍然在努力接收推送信息,我會聯繫Urban Airships支持或在github上發佈問題。完整的日誌將是必要的。

+0

感謝您的回覆。我有個問題。 iOS中的預期行爲如下?當應用程序運行前臺並收到推送時,該設備將不會通知用戶,但通知將與其他通知一起列出?此外,您提到可以在UAPush實例中更改此設置。 我一直在看通知列表,當我試圖推動,沒有看到任何東西。我想我可能不得不發佈一個問題。我已聯繫過UA,但我們客戶的服務水平沒有支持。 – GX2TAP

+0

蘋果公司認爲應用程序可以處理推送,並且不會向iOS 10發佈任何通知。現在,他們允許設置前臺演示文稿選項。你可以在這裏設置默認值 - http://docs.urbanairship.com/reference/libraries/ios/latest/Classes/UAPush.html#/c:objc(cs)UAPush(py)defaultPresentationOptions。他們可能會讓你在社區論壇發帖,但他們很快回復。 – ralepinski

+0

謝謝。我會讓我的下一步。感謝您的反饋。 – GX2TAP

0

對我來說,問題在於我在前臺測試了應用程序,iOS沒有在應用程序運行時顯示通知。我必須添加以下內容才能在前臺工作併發出聲音。

UAirship.Push.DefaultPresentationOptions = UserNotifications.UNNotificationPresentationOptions.Alert | UserNotifications.UNNotificationPresentationOptions.Sound; 
相關問題