2013-04-18 57 views
3

我有一個Windows Phone 8應用程序和一些額外的功能,只能用於完整版本。Windows Phone 8 IsTrial Marketplace

所以上的按鈕

if ((Application.Current as App).IsTrial) 
{ 
    Buy() 
} 
else 
{ 
    //full feature 
} 


private void Buy() 
    { 
     MarketplaceDetailTask marketplaceDetailTask = new MarketplaceDetailTask(); 
     marketplaceDetailTask.ContentType = MarketplaceContentType.Applications; 
     marketplaceDetailTask.ContentIdentifier = "82a23635-5bd9-df11-a844-00237de2db9e"; 
     marketplaceDetailTask.Show(); 
    } 
  1. 用戶點擊這是我必須做的?
  2. 當人購買應用程序時,IsTrial會自動設置爲false嗎?
  3. 如果我現在還不知道我的應用程序的 標識符,我該如何更改ContentIdentifier?
  4. 在將應用程序放入商店之前,可以更改ContentIdentifier嗎?

的App.xaml

/// <summary> 
    /// The LicenseInformation class enables an application to determine 
    /// if it is running under a trial license. 
    /// </summary> 
    private static LicenseInformation _licenseInfo = new LicenseInformation(); 


    /// <summary> 
    /// This property is used to cache the license information while the application is running. 
    /// The application uses the property whenever the current license information needs to be checked. 
    /// </summary> 
    private static bool _isTrial = true; 
    public bool IsTrial 
    { 
     get 
     { 
      return _isTrial; 
     } 
    } 


    /// <summary> 
    /// Check the current license information for this application 
    /// </summary> 
    private void CheckLicense() 
    { 

     _isTrial = _licenseInfo.IsTrial(); 

    } 
+0

你測試了你的代碼嗎? –

+0

一切工作,因爲它應該工作。但我的意思是,如果我把我的應用程序放在應用程序商店中,IsTrial會在用戶購買應用程序時自動激活嗎?我無法將'(Application.Current as App)'.IsTrial'設置爲true,因爲它是ReadOnly。 – Rudi

+0

有辦法通過嘲笑購買來測試此代碼。我建議你這樣做。 –

回答

3

關於你的第二個問題。

是的,Microsoft根據用戶操作設置了LicenseInformation.IsTrial值。如果用戶購買該應用程序,則將IsTrial設置爲false。

您應該在提交到商店之前測試所有購買場景。您使用CurrentAppSimulator class進行測試。它與本地XML文件一起使用。您使用每個方案的模擬licenseinfomation填充XML文件。

關注問題3,您不需要指定GUID,如果您將ContentIdentifier留空,則操作系統將爲您查找您的應用程序GUID。

+0

您的意思是說如果用戶購買了應用程序,那麼IsTrail設置爲false? – webdad3

+0

@Jeffv,是的,這就是我的意思。 :> –