public static void BuildWelcomeScene() { #if SA_DEVELOPMENT_PROJECT AN_TestManager.ApplyExampleConfig(); ISN_TestManager.ApplyExampleConfig(); #endif PlayerSettings.productName = "Ultimate Mobile"; var playerOptions = new BuildPlayerOptions(); playerOptions.scenes = s_ExampleScenes.ToArray(); switch (EditorUserBuildSettings.activeBuildTarget) { case BuildTarget.iOS: playerOptions.target = BuildTarget.iOS; playerOptions.locationPathName = "ultimate_mobile_plugin"; break; case BuildTarget.Android: playerOptions.target = BuildTarget.Android; playerOptions.locationPathName = "ultimate_mobile_plugin.apk"; break; default: UM_DialogsUtility.ShowMessage("Wrong Platform", "Make sure current editor platform set to iOS or Android"); break; } playerOptions.options = BuildOptions.Development | BuildOptions.AutoRunPlayer; BuildPipeline.BuildPlayer(playerOptions); }
private static void ProcessCompletedTransaction(UM_iTransaction transaction) { //Our product has been successfully purchased or restored //So we need to provide content to our user depends on productIdentifier //In case you want to run your custom purchase validation, you might want to get full transaction info //provided by a platform. Lear how to do it here: //https://unionassets.com/ultimate-mobile-pro/advanced-use-cases-849 switch (transaction.ProductId) { case GameConfig.k_10AmmoPack: Main.GameData.AddAmmo(10); break; default: //All our other products are skins so, let's unlock it Main.GameData.UnlockSkin(transaction.ProductId); //We also need to update skins UI, once skin is unlocked Main.GameUI.RefreshSkinsOptions(); var product = UM_InAppService.Client.GetProductById(transaction.ProductId); UM_DialogsUtility.ShowMessage("Thank you!", $"You can now try new {product.Title} skin!"); break; } UM_Preloader.UnlockScreen(); UM_InAppService.Client.FinishTransaction(transaction); }
//-------------------------------------- // UM_iInAppClient //-------------------------------------- public void AddPayment(string productId) { var transactionsList = GetTransactionsList(); if (transactionsList.productIds.Contains(productId)) { UM_DialogsUtility.ShowMessage("Restored", "Product with id " + productId + " has been already purchased."); var transaction = new UM_EditorTransaction(productId, UM_TransactionState.Purchased); UpdateTransaction(transaction); return; } AddPendingTransaction(productId); UM_EditorAPIEmulator.WaitForNetwork(() => { UM_iTransaction transaction; if (productId.Equals(UM_InAppService.TEST_ITEM_UNAVAILABLE)) { transaction = new UM_EditorTransaction(productId, UM_TransactionState.Failed); } else { transaction = new UM_EditorTransaction(productId, UM_TransactionState.Purchased); } UpdateTransaction(transaction); }); }
private void iOSOnlySetup() { m_RegisterForRemoteNotifications.onClick.AddListener(ISN_UIApplication.RegisterForRemoteNotifications); ISN_UIApplication.ApplicationDelegate.DidRegisterForRemoteNotifications.AddListener((result) => { if (result.IsSucceeded) { var token = result.DeviceTokenUTF8; UM_DialogsUtility.ShowMessage("Register For Remote Notifications", "ANS token string:" + token); Debug.Log("ANS token string:" + token); } else { UM_DialogsUtility.ShowMessage("Register For Remote Notifications", "Error: " + result.Error.Message); Debug.Log("Error: " + result.Error.Message); } }); m_iOSNotificationTitle.text = "Wake up!"; m_iOSNotificationBody.text = "Rise and shine! It's morning time!"; m_iOSNotificationBadge.text = "1"; m_iOSNotificationSchegule.onClick.AddListener(ScheduleIOSNotification); m_iOSClearAppBadges.onClick.AddListener(() => { ISN_UIApplication.ApplicationIconBadgeNumber = 0; }); }
private void PrintResult(UM_MediaResult result) { if (result.IsSucceeded) { var media = result.Media; var mediaThumbnail = media.Thumbnail; Debug.Log("Thumbnail width: " + mediaThumbnail.width + " / height: " + mediaThumbnail.height); Debug.Log("media.Type: " + media.Type); Debug.Log("media.Path: " + media.Path); UM_DialogsUtility.ShowMessage("Success", "Image Info \n " + "Thumbnail width: " + mediaThumbnail.width + " / height: " + mediaThumbnail.height + " \n " + "media.Type: " + media.Type + " \n " + "media.Path: " + media.Path); ApplyImageToGUI(mediaThumbnail); //path can be null when we taking a picture directly from a camera. //ios will not save it on a disk if (!string.IsNullOrEmpty(media.Path)) { byte[] movieBytes = File.ReadAllBytes(media.Path); Debug.Log("picked file bytes size : " + movieBytes.Length); } } else { UM_DialogsUtility.ShowMessage("Failed", result.Error.FullMessage); } }
public void OnTransactionUpdated(UM_iTransaction transaction) { switch (transaction.State) { case UM_TransactionState.Restored: case UM_TransactionState.Purchased: ProcessCompletedTransaction(transaction); break; case UM_TransactionState.Deferred: //Only for iOS //iOS 8 introduces Ask to Buy, which lets parents approve any //purchases initiated by children //You should update your UI to reflect this deferred state, //and expect another Transaction Complete to be called again //with a new transaction state //reflecting the parent’s decision or after the transaction times out. //Avoid blocking your UI or game play while waiting //for the transaction to be updated. UM_Preloader.UnlockScreen(); break; case UM_TransactionState.Failed: //Our purchase flow is failed. //We can unlock interface and tell user that the purchase is failed. UM_Preloader.UnlockScreen(); UM_InAppService.Client.FinishTransaction(transaction); UM_DialogsUtility.ShowMessage("Error", "We wasn't able to process your transaction. \n" + transaction.Error.Message); break; } }
private void CreateNotificationWithInterval(int delay) { var client = UM_NotificationCenter.Client; var content = new UM_Notification(); content.SetTitle("Title X"); content.SetBody("Body message X"); content.SetSoundName(UM_SamplesConfig.NotificationSoundSampleFile); content.SetSmallIconName(UM_SamplesConfig.NotificationIconSampleFile); var requestId = SA_IdFactory.NextId; //2 seconds var trigger = new UM_TimeIntervalNotificationTrigger(delay); var request = new UM_NotificationRequest(requestId, content, trigger); client.AddNotificationRequest(request, (result) => { if (result.IsSucceeded) { UM_DialogsUtility.ShowMessage("Succeeded", "Notification was successfully scheduled."); } else { UM_DialogsUtility.ShowMessage("Failed", result.Error.FullMessage); } }); }
public static void PrintSharingResult(SA_Result result) { if (result.IsSucceeded) { UM_DialogsUtility.ShowMessage("Result", "Sharing Completed."); Debug.Log("Sharing Completed."); } else { UM_DialogsUtility.ShowMessage("Result", "Failed to share: " + result.Error.FullMessage); Debug.Log("Failed to share: " + result.Error.FullMessage); } }
private void Start() { SetStoreActiveState(false); m_Connect.onClick.AddListener(() => { var observer = new UM_TransactionObserverExample(); UM_InAppService.Client.SetTransactionObserver(observer); UM_InAppService.Client.Connect((connectionResult) => { if (connectionResult.IsSucceeded) { //You are now connected to the payment service. //Also all product's info are updated at this point from according to server values. SetStoreActiveState(true); PrintAvailableProductsInfo(); UM_DialogsUtility.ShowMessage("Connection Succeeded", "In App Service is now connected and ready to use!"); } else { //Connection failed. UM_DialogsUtility.ShowMessage("Connection Failed", connectionResult.Error.FullMessage); } }); }); m_PurchaseConsumable.onClick.AddListener(() => { StartPayment(UM_ProductType.Consumable); }); m_PurchaseNonConsumable.onClick.AddListener(() => { StartPayment(UM_ProductType.NonConsumable); }); m_TestFailedPurchase.onClick.AddListener(() => { UM_InAppService.Client.AddPayment("non_existed_product_id"); }); m_RestoreTransactions.onClick.AddListener(() => { Restore(); }); m_CheckAccess.onClick.AddListener(() => { AN_LicenseChecker.CheckAccess((result) => { if (result.IsSucceeded) { UM_DialogsUtility.ShowMessage("Policy Code", result.PolicyCode.ToString()); } else { UM_DialogsUtility.ShowMessage("AN_LicenseChecker error", result.Error.FullMessage); } }); }); m_SubscriptionReplace.onClick.AddListener(SubscriptionReplace); }
private void iOSSetup() { //External URL Calls var url = ISN_UIApplication.ApplicationDelegate.GetLaunchURL(); if (!string.IsNullOrEmpty(url)) { UM_DialogsUtility.ShowMessage("GetLaunchURL", "App is launched via external url"); } ISN_UIApplication.ApplicationDelegate.OpenURL.AddListener((string openUrl) => { UM_DialogsUtility.ShowMessage("OpenURL", "URL request received: " + openUrl); }); }
private void PrintTransactionInfo(UM_iTransaction transaction) { Debug.Log("transaction.Id: " + transaction.Id); Debug.Log("transaction.State: " + transaction.State); Debug.Log("transaction.ProductId: " + transaction.ProductId); Debug.Log("transaction.Timestamp: " + transaction.Timestamp); var title = "Transaction Updated."; var message = string.Format("ProductId: {0}. TransactionId: {1}. State: {2}", transaction.ProductId, transaction.Id, transaction.State); UM_DialogsUtility.ShowMessage(title, message); }
private void Awake() { UpdateStatusBar(); var observer = new UM_TransactionObserverExample(); observer.OnProductUnlock += UpdateStatusBar; UM_InAppService.Client.SetTransactionObserver(observer); m_ConnectButton.onClick.AddListener(() => { m_ConnectButton.interactable = false; UM_InAppService.Client.Connect(result => { if (result.IsSucceeded) { foreach (var purchaseButton in m_PurchaseButtons) { purchaseButton.UpdateButtonView(); } } else { m_ConnectButton.interactable = true; UM_DialogsUtility.ShowMessage("Error", result.Error.FullMessage); } }); }); m_ClearPlayerPrefs.onClick.AddListener(() => { UM_RewardManager.Reset(); UpdateStatusBar(); }); m_RestorePurchases.onClick.AddListener(UM_InAppService.Client.RestoreCompletedTransactions); m_RestorePurchases.gameObject.SetActive(Application.platform == RuntimePlatform.IPhonePlayer || Application.isEditor); foreach (var purchaseButton in m_PurchaseButtons) { purchaseButton.Button.onClick.AddListener(() => { UM_InAppService.Client.AddPayment(purchaseButton.ProductId); }); } }
public void SaveTogal() { //Generating sample red texture with 32x32 resolution var gallery = UM_Application.GalleryService; gallery.SaveImage(Screenshot, "sample_black_image.png", (result) => { if (result.IsSucceeded) { UM_DialogsUtility.ShowMessage("Result", "Sharing Completed."); } else { Debug.Log("Failed to save an Image: " + result.Error.FullMessage); } }); }
private void iOSOnlySetup() { m_RegisterForRemoteNotifications.onClick.AddListener(ISN_UIApplication.RegisterForRemoteNotifications); ISN_UIApplication.ApplicationDelegate.DidRegisterForRemoteNotifications.AddListener((result) => { if (result.IsSucceeded) { var token = result.DeviceTokenUTF8; UM_DialogsUtility.ShowMessage("Register For Remote Notifications", "ANS token string:" + token); Debug.Log("ANS token string:" + token); } else { UM_DialogsUtility.ShowMessage("Register For Remote Notifications", "Error: " + result.Error.Message); Debug.Log("Error: " + result.Error.Message); } }); }
// Start is called before the first frame update void Start() { MakeNewRecorder(); m_StartRecord.onClick.AddListener(() => { MakeNewRecorder(); m_Recorder.Record(); }); m_StopRecord.onClick.AddListener(m_Recorder.Stop); m_SaveGif.onClick.AddListener(m_Recorder.Save); m_PlayButton.onClick.AddListener(m_Player.Play); AddFitter(m_CameraView.gameObject); AddFitter(m_PlayerView.gameObject); var client = UM_SocialService.SharingClient; m_SystemShareDialog.onClick.AddListener(() => { client.SystemSharingDialog(GetSharingContent(), UM_SharingExample.PrintSharingResult); }); m_ShareWithFacebook.onClick.AddListener(() => { if (Application.platform == RuntimePlatform.Android) { UM_DialogsUtility.ShowMessage("Text & Url Sharing is denied.", "You need to use Facebook SDK for sharing. As Facebook will not allow sharing through Intent"); } else { client.ShareToFacebook(GetSharingContent(), UM_SharingExample.PrintSharingResult); } }); m_ShareWithTwitter.onClick.AddListener(() => { client.ShareToTwitter(GetSharingContent(), UM_SharingExample.PrintSharingResult); }); FillStates(); OnRecorderStateChanged(m_Recorder.State); SetSharingButtonsInteractable(false); }
public void LoadData(UM_iSavedGameMetadata game) { var client = UM_GameService.SavedGamesClient; client.LoadGameData(game, (result) => { if (result.IsSucceeded) { var text = Encoding.ASCII.GetString(result.Data); UM_DialogsUtility.ShowMessage("Saved Game Data Loaded", text); //Restore your game progress here } else { UM_DialogsUtility.DisplayResultMessage(result); } }); }
private void Start() { m_LogIn.onClick.AddListener(() => { m_LogIn.interactable = false; SA_FB.Login(result => { if (result.IsSucceeded) { } else { m_LogIn.interactable = true; UM_DialogsUtility.ShowMessage("Login Failed", result.Error.FullMessage); } }); }); }
private void SubscriptionReplace() { var oldProductId = "old_subscription_id"; var newProductId = "new_subscription_id"; AN_Billing.PurchaseSubscriptionReplace(new List <string> { oldProductId }, newProductId, string.Empty, (result) => { if (result.IsSucceeded) { UM_DialogsUtility.ShowMessage("Replace Succeeded", result.Purchase.ToString()); } else { UM_DialogsUtility.ShowMessage("Failed", result.Error.FullMessage); } }); }
private void OnFileSaved(int workerId, string path) { m_StatusBarText.text = "File Saved: " + path; var uploader = new SG_GiphyUploader(GiphyApiKey); uploader.Upload(path, (result) => { if (result.IsSucceeded) { m_SharableUrl = result.ShareUrl; m_StatusBarText.text = "GIF uploaded url: " + result.ShareUrl; SetSharingButtonsInteractable(true); } else { m_StatusBarText.text = "Upload Failed: " + result.meta.msg; UM_DialogsUtility.ShowMessage("Upload Failed", result.meta.msg); } }); }
public PaymentService() { m_Client = UM_InAppService.Client; var observer = new TransactionObserver(); m_Client.SetTransactionObserver(observer); m_Client.Connect(connectionResult => { if (connectionResult.IsSucceeded) { OnServiceConnected?.Invoke(); } else { UM_DialogsUtility.ShowMessage("Payment Service Connection Failed", connectionResult.Error.FullMessage); } IsConnected = connectionResult.IsSucceeded; }); }
public static void SubscribeToTheNotificationEvents() { var client = UM_NotificationCenter.Client; var startRequest = client.LastOpenedNotification; if (startRequest != null) { UM_DialogsUtility.ShowMessage("Launched via Notification", GetNotificationInfo(startRequest)); //if this isn't null on your app launch, means user launched your app by clicking on notification icon } client.OnNotificationReceived.AddListener(request => { //Notification was received while app is running UM_DialogsUtility.ShowMessage("Notification Received", GetNotificationInfo(request)); }); client.OnNotificationClick.AddListener(request => { //User clicked on notification while app is running UM_DialogsUtility.ShowMessage("Restored from background via Notification", GetNotificationInfo(request)); }); }
private void StartPayment(UM_ProductType productType) { UM_iProduct validProduct = null; foreach (var product in UM_InAppService.Client.Products) { if (product.Type == productType && product.IsActive) { validProduct = product; break; } } if (validProduct != null) { UM_InAppService.Client.AddPayment(validProduct.Id); } else { var message = string.Format("You don't have any {0} products set.", productType); UM_DialogsUtility.ShowMessage("Not Found", message); } }
private void InitIOSDialogs() { m_DateTimePicker.onClick.AddListener(() => { DateTime starDate = DateTime.Now; starDate = starDate.AddDays(-20); ISN_UIDateTimePicker picker = new ISN_UIDateTimePicker(); picker.SetDate(starDate); picker.Show((DateTime date) => { UM_DialogsUtility.ShowMessage("Completed", "User picked date: " + date.ToLongDateString()); }); }); m_DatePicker.onClick.AddListener(() => { //20 days ago var starDate = DateTime.Now; starDate = starDate.AddDays(-20); var picker = new ISN_UIDateTimePicker(); picker.SetDate(starDate); picker.DatePickerMode = ISN_UIDateTimePickerMode.Date; picker.Show(date => { UM_DialogsUtility.ShowMessage("Completed", "User picked date: " + date.ToLongDateString()); }); }); m_TimePicker.onClick.AddListener(() => { //20 hours ago var starDate = DateTime.Now; starDate = starDate.AddHours(-20); var picker = new ISN_UIDateTimePicker(); picker.SetDate(starDate); picker.DatePickerMode = ISN_UIDateTimePickerMode.Time; picker.MinuteInterval = 30; picker.Show(date => { UM_DialogsUtility.ShowMessage("Completed", "User picked date: " + date.ToLongDateString()); }); }); m_CountdownTimer.onClick.AddListener(() => { var picker = new ISN_UIDateTimePicker(); picker.DatePickerMode = ISN_UIDateTimePickerMode.CountdownTimer; picker.MinuteInterval = 10; //Set countdown start duration var hours = 5; var minutes = 20; var seconds = 0; var span = new TimeSpan(hours, minutes, seconds); picker.SetCountDownDuration(span); picker.Show(date => { UM_DialogsUtility.ShowMessage("Completed", "User picked date: " + date.ToLongDateString()); }); }); }
public void OnRoomCreated(int statusCode, AN_Room room) { UM_DialogsUtility.ShowMessage("OnRoomCreated", "Status Code: " + statusCode); }