[英]Windows phone 8 push notification null channel uri
我知道這個問題已經提出很多次了,但是找不到答案。
我正在嘗試使用以下代碼在我的應用中設置推送通知,但是我遇到了通道uri null問題。
我已經在相同的網絡條件下(工作WiFi-家庭WiFi-3G)在4種不同的設備+模擬器上嘗試了該應用程序,其中2台設備均為Lumia 920,都無法獲取頻道uri,而其他2台設備為HTC 8X和Lumia 820可以成功獲取頻道uri並注冊進行推送。
仿真器還可以成功獲取通道uri。
在Lumia 920的其中一個上,它設法獲得了頻道uri,但是我再次卸載並安裝了該應用程序,從那時起就無法獲得任何頻道uri。
以下是我的情況:
1-在3G上安裝的Lumia 920 Black可以正常工作,卸載/重新安裝后可以在任何連接上停止工作(3G-工作WiFi-家用WiFi)2-在3G上安裝的Lumia 920 Yellow在-3G-工作WiFi-家用WIfi從未設法獲得頻道uri 3 -3G上的HTC 8X-工作WiFi-家庭WiFi在所有3個網絡上均表現出色4- Lumia 820與HTC 8X相同,表現出色
請注意,其他應用程序上的推送通知在所有4種設備上均能正常工作。
我非常感謝您對頻道null uri的任何反饋/建議
下面是我使用的代碼,它與MSDN提供的代碼相同
public MainPage()
{
/// Holds the push channel that is created or found.
HttpNotificationChannel pushChannel;
// The name of our push channel.
string channelName = "ToastSampleChannel";
InitializeComponent();
// Try to find the push channel.
pushChannel = HttpNotificationChannel.Find(channelName);
// If the channel was not found, then create a new connection to the push service.
if (pushChannel == null)
{
pushChannel = new HttpNotificationChannel(channelName);
// Register for all the events before attempting to open the channel.
pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
// Register for this notification only if you need to receive the notifications while your application is running.
pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
pushChannel.Open();
// Bind this new channel for toast events.
pushChannel.BindToShellToast();
}
else
{
// The channel was already open, so just register for all the events.
pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
// Register for this notification only if you need to receive the notifications while your application is running.
pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
// Display the URI for testing purposes. Normally, the URI would be passed back to your web service at this point.
System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString());
MessageBox.Show(String.Format("Channel Uri is {0}",
pushChannel.ChannelUri.ToString()));
}
}
我也遇到過同樣的問題。 通過將我的HTC Windows Phone設置為正確的日期和時間可以解決此問題。一旦我自動設置了日期和時間,我的混合應用程序wp8成功注冊了pushplugin,並收到了MPNS Channeluri。
ChannelUri為空,因為正在開發的新手機無法正確設置其日期和時間。 一旦我將時間設置為手動設置,然后將其固定為時間,日期和區域,然后又切換回自動設置,一切工作正常,例如SSL證書,Windows Phone更新以及最重要的ChannelUri;)
嘗試進入“設置”>“電話+ SIM”並關閉“數據連接”選項,這有時有用嗎?
您是否嘗試過更改設置>數據感知中的選項? 有沒有限制后台數據的選項?
是否啟用了省電模式? 當電池電量不足等情況時,這會限制使用。
同樣如上所述,您是否在設備上檢查了日期和時間? 可能是由於日期和時間的自動設置引起的。 您可以手動修復此問題,然后切換回自動。 有用。
嘗試使用本地wifi連接而不是手機數據連接。 根據此處的注釋之一禁用電話的“數據連接”將實現此結果。 盡管我嘗試了此操作並失敗了,但它使我注意到我的手機未連接到我們的wifi路由器。
注意:就我而言,我們的蜂窩網絡覆蓋范圍很差,因此我們使用特殊的沃達豐路由器,該路由器通過固網Internet連接重定向所有手機數據,通話等。 一旦繞過那個路由器,我就會收到一個ChannelUri。 我還嘗試了在工作中使用不同信號塔的電話/應用,這很好。
我嘗試手動設置日期,但沒有任何效果。 最終對我有用的是實際上在沒有SIM卡的情況下啟動手機,關機,重新插入SIM卡並重新啟動。 這使我能夠再次獲得ChannelUri。
懷疑這可能與TripVoltage的建議有關,后者建議切換SIM的數據連接 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.