public void RegisterForRemoteNotifications(UnityEngine.iOS.NotificationType notificationTypes) { #if (UNITY_IPHONE && !UNITY_EDITOR && PUSH_ENABLED) || SA_DEBUG_MODE NotificationServices.RegisterForRemoteNotificationTypes(notificationTypes); DeviceTokenListner.Create(); #endif }
public async Task CallNotificationManagerForEditNewCocktail_WithCorrectParameters() { var options = TestUtils.GetOptions(nameof(CallNotificationManagerForEditNewCocktail_WithCorrectParameters)); var adminName = "pesho"; var id = "1"; var oldName = "oldCocktail"; var cocktailName = "newCocktail"; var admin = new AppUser { Id = id, UserName = adminName }; _userServices.Setup(x => x.GetUsernameById(id)) .ReturnsAsync(admin.UserName); _userServices.Setup(x => x.GetAdmin()) .ReturnsAsync(admin); _iNotificationManager.Setup(x => x.CocktailEditedDescription(adminName, oldName, cocktailName)) .Returns($"LALALALA"); using (var arrangeContext = new CMContext(options)) { arrangeContext.Add(admin); await arrangeContext.SaveChangesAsync(); var sut = new NotificationServices(arrangeContext, _userServices.Object, _iNotificationManager.Object); await sut.CocktailEditNotificationToAdminAsync(id, oldName, cocktailName); _iNotificationManager.Verify(x => x.CocktailEditedDescription(adminName, oldName, cocktailName), Times.Once()); } }
// Use this for initialization void Awake() { #if UNITY_IOS NotificationServices.RegisterForRemoteNotificationTypes(RemoteNotificationType.Alert | RemoteNotificationType.Badge | RemoteNotificationType.Sound); #endif ParsePush.ParsePushNotificationReceived += (sender, args) => { #if UNITY_ANDROID AndroidJavaClass parseUnityHelper = new AndroidJavaClass("com.parse.ParsePushUnityHelper"); AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject currentActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity"); // Call default behavior. parseUnityHelper.CallStatic("handleParsePushNotificationReceived", currentActivity, args.StringPayload); #elif UNITY_IOS IDictionary <string, object> payload = args.Payload; foreach (var key in payload.Keys) { Debug.Log("Payload: " + key + ": " + payload[key]); } #endif }; }
void OnApplicationPause(bool paused) { if (paused) { Schedule(User.GetLifesManager.GetTimeWhenAllLifesWillRestored(), GameStrings.GetLocalizedString(GameStrings.LocalNotifications_AllLifesRestored), IdEvent_AllLifesRestored); DateTime date = DateTime.Now; date = date.AddDays(1); Schedule(date, GameStrings.GetLocalizedString(GameStrings.LocalNotifications_LaunchMe24Hours), IdEvent_RememberAfter24hours); date = date.AddDays(1); Schedule(date, GameStrings.GetLocalizedString(GameStrings.LocalNotifications_LaunchMe48Hours), IdEvent_RememberAfter48hours); date = date.AddDays(5); Schedule(date, GameStrings.GetLocalizedString(GameStrings.LocalNotifications_LaunchMe7Days), IdEvent_RememberAfter7Days); } else { LocalNotification setToZeroBadge = new LocalNotification(); setToZeroBadge.fireDate = System.DateTime.Now; setToZeroBadge.applicationIconBadgeNumber = -1000; setToZeroBadge.hasAction = true; NotificationServices.PresentLocalNotificationNow(setToZeroBadge); CancelAllEvents(); } }
// Clears all notifications. public static void ClearAll() { NotificationServices.ClearRemoteNotifications(); #if !UNITY_EDITOR clearAll(); #endif }
public async Task CallUserManagerForDeleteBar_WithCorrectParameters() { var options = TestUtils.GetOptions(nameof(CallUserManagerForDeleteBar_WithCorrectParameters)); var adminName = "pesho"; var id = "1"; var barName = "newBar"; var admin = new AppUser { Id = id, UserName = adminName }; _userServices.Setup(x => x.GetUsernameById(id)) .ReturnsAsync(admin.UserName); _userServices.Setup(x => x.GetAdmin()) .ReturnsAsync(admin); _iNotificationManager.Setup(x => x.BarDeletedDescription(adminName, barName)) .Returns($"New Bar notification: User: {adminName}, just added new Bar with name: {barName}"); using (var arrangeContext = new CMContext(options)) { arrangeContext.Add(admin); await arrangeContext.SaveChangesAsync(); var sut = new NotificationServices(arrangeContext, _userServices.Object, _iNotificationManager.Object); await sut.BarDeletedNotificationToAdminAsync(id, barName); _userServices.Verify(u => u.GetUsernameById(id), Times.Once()); } }
public JsonResult Get(DatatableModel dt, NotificationModel filters) { try { NotificationServices service = new NotificationServices(); PagerModel pager = dt.ToPager(); var collection = service.Get(pager, filters); return(Json(new { status = UI.Status.Success, sEcho = dt.sEcho, iTotalRecords = pager.TotalRecords, iTotalDisplayRecords = pager.TotalRecords, aaData = collection }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(new JsonResult { Data = new { status = UI.Status.Error, data = ex.Message }, }); } }
// public IEnumerator Awake () // { // return 0; // //base.Awake (); // //DontDestroyOnLoad (this.gameObject); // } // Use this for initialization public override void Start() { //Ag.GameStt.TitleSceneBegan (); base.Start(); //CheckWasServerVision (); //Debug.Log ("Getbool" + PreviewLabs.PlayerPrefs.GetBool ("BgmSoundOff")); Screen.sleepTimeout = SleepTimeout.NeverSleep; #if UNITY_IPHONE NotificationServices.RegisterForRemoteNotificationTypes(RemoteNotificationType.Alert | RemoteNotificationType.Badge | RemoteNotificationType.Sound); Ag.LogIntenseWord("NotificationServices. Register For Remote NotificationTypes "); #endif (" Title :: Start ").HtLog(); //Ag.mFBOrder = "ConNet"; GameInit(); StartCoroutine(WaitAndPrint()); JCE.JceUrgentNoticePT(Ag.mySelf); JCE.JceTextNoticePT(Ag.mySelf); if (AgUtil.IsLGeVuModel()) { Screen.SetResolution((Screen.height / 2) * 3, Screen.height, true); } }
//---------------------------------------------------------------------------- // @brief ローカル通知のキャンセル //---------------------------------------------------------------------------- public static void CancelAllNotifications() { if (Patcher.Instance.GetLocalNotificationCancelDisable()) { return; } #if LOCAL_NOTIFICATION_EDITOR #if DEBUG_LOG // Editor Debug.Log("CancelAllNotification"); #endif #elif LOCAL_NOTIFICATION_ANDROID // Android ELANManager.CancelAllNotifications(); #elif LOCAL_NOTIFICATION_IOS // iOS if (NotificationServices.localNotificationCount >= 0) { LocalNotification notification = new LocalNotification(); if (notification != null) { notification.applicationIconBadgeNumber = -1; NotificationServices.PresentLocalNotificationNow(notification); NotificationServices.CancelAllLocalNotifications(); NotificationServices.ClearLocalNotifications(); } } #endif }
public async Task AddNotificationMessageToDB_WithCorrectParameters() { var options = TestUtils.GetOptions(nameof(AddNotificationMessageToDB_WithCorrectParameters)); var adminName = "pesho"; var id = "1"; var barName = "newBar"; var admin = new AppUser { Id = id, UserName = adminName }; _userServices.Setup(x => x.GetAdmin()) .ReturnsAsync(admin); _iNotificationManager.Setup(x => x.QuickMessageDescription(adminName, "email", "msg")) .Returns("msg"); using (var arrangeContext = new CMContext(options)) { arrangeContext.Add(admin); await arrangeContext.SaveChangesAsync(); var sut = new NotificationServices(arrangeContext, _userServices.Object, _iNotificationManager.Object); Assert.AreEqual(0, arrangeContext.Notifications.Count()); await sut.CreateNewMessageAsync(adminName, "email", "msg"); Assert.AreEqual(1, arrangeContext.Notifications.Count()); Assert.AreEqual("msg", arrangeContext.Notifications.First().Description); Assert.AreEqual(adminName, arrangeContext.Notifications.First().Username); } }
public async Task CallNotificationManagerForMsg_WithCorrectParameters() { var options = TestUtils.GetOptions(nameof(CallNotificationManagerForMsg_WithCorrectParameters)); var adminName = "pesho"; var id = "1"; var barName = "newBar"; var admin = new AppUser { Id = id, UserName = adminName }; _userServices.Setup(x => x.GetAdmin()) .ReturnsAsync(admin); _iNotificationManager.Setup(x => x.QuickMessageDescription("name", "email", "msg")) .Returns("msg"); using (var arrangeContext = new CMContext(options)) { arrangeContext.Add(admin); await arrangeContext.SaveChangesAsync(); var sut = new NotificationServices(arrangeContext, _userServices.Object, _iNotificationManager.Object); await sut.CreateNewMessageAsync("name", "email", "msg"); _iNotificationManager.Verify(x => x.QuickMessageDescription("name", "email", "msg"), Times.Once()); } }
IEnumerator CreateIosInstalliation() { NotificationServices.RegisterForRemoteNotificationTypes(RemoteNotificationType.Alert | RemoteNotificationType.Badge | RemoteNotificationType.Sound); //wait for token while (NotificationServices.deviceToken == null) { yield return(null); } Debug.Log("parse notification Token gotten"); var token = NotificationServices.deviceToken; var tokenString = System.BitConverter.ToString(token).Replace("-", "").ToLower(); var obj = CreateInstallationObject(tokenString, "ios"); obj.SaveAsync().ContinueWith(t => { if (t.IsFaulted || obj.ObjectId == null) { Debug.LogError("save parse installiation failed"); } else { Debug.LogError("save parse installiation ok"); PlayerPrefs.SetString("currentInstallation", obj.ObjectId); } }); }
public void NotificationOnOff() { if (GameData.isMusicON) { MainDriver.Instance.PlayButtonSound(); } if (GameData.isNotifcationON) { GameData.isNotifcationON = false; notificationText.text = "OFF"; notificationText.color = offColor; } else { GameData.isNotifcationON = true; notificationText.text = "ON"; notificationText.color = onColor; #if UNITY_ANDROID EtceteraAndroid.cancelNotification(Constants.H4); EtceteraAndroid.cancelNotification(Constants.H8); EtceteraAndroid.cancelNotification(Constants.D1); EtceteraAndroid.cancelNotification(Constants.D3); EtceteraAndroid.cancelNotification(Constants.D7); EtceteraAndroid.cancelNotification(Constants.D14); EtceteraAndroid.cancelNotification(Constants.D30); EtceteraAndroid.cancelAllNotifications(); #elif UNITY_IOS NotificationServices.ClearLocalNotifications(); NotificationServices.CancelAllLocalNotifications(); #endif } PlayerPrefs.SetBool(Constants.KEY_NOTIFICATIONS, GameData.isNotifcationON); PlayerPrefs.Flush(); }
public async Task ThrowCorrectMessage_WhenPassedBarNameIsNull() { var options = TestUtils.GetOptions(nameof(ThrowCorrectMessage_WhenPassedBarNameIsNull)); var adminName = "pesho"; var id = "1"; var barName = "newBar"; var admin = new AppUser { Id = id, UserName = adminName }; _userServices.Setup(x => x.GetUsernameById(id)) .ReturnsAsync(admin.UserName); _userServices.Setup(x => x.GetAdmin()) .ReturnsAsync(admin); _iNotificationManager.Setup(x => x.BarAddedDescription(adminName, barName)) .Returns($"New Bar notification: User: {adminName}, just added new Bar with name: {barName}"); using (var assertContext = new CMContext(options)) { var sut = new NotificationServices(assertContext, _userServices.Object, _iNotificationManager.Object); var ex = await Assert.ThrowsExceptionAsync <MagicException>( async() => await sut.BarCreateNotificationToAdminAsync(id, null)); Assert.AreEqual(ExceptionMessages.BarNameNull, ex.Message); } }
public override bool SetPushNotificationsEnabled(bool enabled) { // Should be done before (enable == m_pushEnabled) check in order to disable push notifications before Manager initialization UnityEngine.PlayerPrefs.SetInt(m_pushEnabledOptionName, enabled ? 1 : 0); if (enabled && !Settings.Instance.PushNotificationsEnabledIOS) { UnityEngine.Debug.LogWarning("Can't enable push notifications: iOS -> Push Notifications are disabled in the UTNotifications Settings"); } if (!Initialized || enabled == m_pushEnabled) { return(PushNotificationsEnabled()); } m_pushEnabled = enabled; if (m_enabled && Settings.Instance.PushNotificationsEnabledIOS) { if (m_pushEnabled) { RegisterForNotifications(); } else { NotificationServices.UnregisterForRemoteNotifications(); } } return(PushNotificationsEnabled()); }
public async Task ThrowCorrectMessage_WhenPassedNewNameIsNull() { var options = TestUtils.GetOptions(nameof(ThrowCorrectMessage_WhenPassedNewNameIsNull)); var adminName = "pesho"; var id = "1"; string cocktailName = null; string oldName = "old"; var admin = new AppUser { Id = id, UserName = adminName }; _userServices.Setup(x => x.GetUsernameById(id)) .ReturnsAsync(admin.UserName); _userServices.Setup(x => x.GetAdmin()) .ReturnsAsync(admin); _iNotificationManager.Setup(x => x.CocktailEditedDescription(adminName, oldName, cocktailName)) .Returns($"LALALALA"); using (var assertContext = new CMContext(options)) { var sut = new NotificationServices(assertContext, _userServices.Object, _iNotificationManager.Object); var ex = await Assert.ThrowsExceptionAsync <MagicException>( async() => await sut.CocktailEditNotificationToAdminAsync(id, oldName, cocktailName)); Assert.AreEqual(ExceptionMessages.CocktailNameNull, ex.Message); } }
public async Task ThrowExceptionForDeleteCocktail_WhenPassedCocktailNameIsNull() { var options = TestUtils.GetOptions(nameof(ThrowExceptionForDeleteCocktail_WhenPassedCocktailNameIsNull)); var adminName = "pesho"; var id = "1"; var cocktailName = "new"; var admin = new AppUser { Id = id, UserName = adminName }; _userServices.Setup(x => x.GetUsernameById(id)) .ReturnsAsync(admin.UserName); _userServices.Setup(x => x.GetAdmin()) .ReturnsAsync(admin); _iNotificationManager.Setup(x => x.CocktailDeletedDescription(adminName, cocktailName)) .Returns("LLALALALALA"); using (var assertContext = new CMContext(options)) { var sut = new NotificationServices(assertContext, _userServices.Object, _iNotificationManager.Object); var ex = await Assert.ThrowsExceptionAsync <MagicException>( async() => await sut.CocktailDeletedNotificationToAdminAsync(id, null)); } }
public async Task AddNotificationToDBForEditCocktailWithCorrectDecription_WithCorrectParameters() { var options = TestUtils.GetOptions(nameof(AddNotificationToDBForEditCocktailWithCorrectDecription_WithCorrectParameters)); var adminName = "pesho"; var id = "1"; var oldName = "oldCocktail"; var cocktailName = "newCocktail"; var admin = new AppUser { Id = id, UserName = adminName }; _userServices.Setup(x => x.GetUsernameById(id)) .ReturnsAsync(admin.UserName); _userServices.Setup(x => x.GetAdmin()) .ReturnsAsync(admin); _iNotificationManager.Setup(x => x.CocktailEditedDescription(adminName, oldName, cocktailName)) .Returns("LALALALALA"); using (var arrangeContext = new CMContext(options)) { arrangeContext.Add(admin); await arrangeContext.SaveChangesAsync(); Assert.AreEqual(0, arrangeContext.Notifications.Count()); var sut = new NotificationServices(arrangeContext, _userServices.Object, _iNotificationManager.Object); await sut.CocktailEditNotificationToAdminAsync(id, oldName, cocktailName); Assert.AreEqual("LALALALALA", arrangeContext.Notifications.First().Description); Assert.AreEqual(adminName, arrangeContext.Notifications.First().Username); } }
//初始化 数据统计 public void InitAccount() { Server curServer = Core.SM.curServer; PlayerManager player = Core.Data.playerManager; #if UNITY_ANDROID && !UNITY_EDITOR if (account == null) { AndroidJavaClass unityClass = new AndroidJavaClass(UNTIFY_CLASS); AndroidJavaObject activity = unityClass.GetStatic <AndroidJavaObject>("currentActivity"); activity.Call("runOnUiThread", new AndroidJavaRunnable(() => { TalkingDataGA.OnStart(TDataAppId, curServer.id.ToString()); account = TDGAAccount.SetAccount(player.PlayerID.ToString()); account.SetGameServer(curServer.id.ToString()); account.SetLevel(player.Lv); })); } #endif #if UNITY_IPHONE NotificationServices.RegisterForRemoteNotificationTypes( RemoteNotificationType.Alert | RemoteNotificationType.Badge | RemoteNotificationType.Sound ); TalkingDataGA.OnStart(TDataAppId, curServer.id.ToString()); account = TDGAAccount.SetAccount(player.PlayerID.ToString()); account.SetGameServer(curServer.id.ToString()); //account.SetLevel(player.Lv); #endif }
public void RegisterForRemoteNotifications(RemoteNotificationType notificationTypes) { #if (UNITY_IPHONE && !UNITY_EDITOR) || SA_DEBUG_MODE NotificationServices.RegisterForRemoteNotificationTypes(notificationTypes); DeviceTokenListner.Create(); #endif }
public void RegisterForRemoteNotifications(NotificationType notificationTypes) { ; #endif #if (UNITY_IPHONE && !UNITY_EDITOR && PUSH_ENABLED) || SA_DEBUG_MODE string sysInfo = SystemInfo.operatingSystem; sysInfo = sysInfo.Replace("iPhone OS ", ""); string[] chunks = sysInfo.Split('.'); int majorVersion = int.Parse(chunks[0]); if (majorVersion >= 8) { _ISN_RegisterForRemoteNotifications((int)notificationTypes); } #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 NotificationServices.RegisterForRemoteNotificationTypes(notificationTypes); #else NotificationServices.RegisterForNotifications(notificationTypes); #endif DeviceTokenListener.Create(); #endif }
void OnApplicationPause(bool pausing) { if (pausing) { } else { #if UNITY_4 foreach (var n in NotificationServices.remoteNotifications) { if (n.userInfo.Contains("notification_id")) { Native_ReceivedRemoteNotification(n.userInfo["notification_id"].ToString()); } } NotificationServices.ClearRemoteNotifications(); #else foreach (var n in UnityEngine.iOS.NotificationServices.remoteNotifications) { if (n.userInfo.Contains("notification_id")) { Native_ReceivedRemoteNotification(n.userInfo["notification_id"].ToString()); } } UnityEngine.iOS.NotificationServices.ClearRemoteNotifications(); #endif } }
//本地推送 你可以传入一个固定的推送时间 public static void NotificationMessage(string message, System.DateTime newDate, bool isRepeat) { #if UNITY_IPHONE if (Application.platform == RuntimePlatform.IPhonePlayer) { //推送时间需要大于当前时间 if (newDate > System.DateTime.Now) { LocalNotification localNotification = new LocalNotification(); localNotification.fireDate = newDate; localNotification.alertBody = message; localNotification.applicationIconBadgeNumber = 1; localNotification.hasAction = true; if (isRepeat) { localNotification.repeatCalendar = CalendarIdentifier.ChineseCalendar; // Repeat per week localNotification.repeatInterval = CalendarUnit.Week; } localNotification.soundName = LocalNotification.defaultSoundName; NotificationServices.ScheduleLocalNotification(localNotification); } } #endif }
public async Task AddNotificationToDB_WithCorrectParameters() { var options = TestUtils.GetOptions(nameof(AddNotificationToDB_WithCorrectParameters)); var adminName = "pesho"; var id = "1"; var barName = "newBar"; var admin = new AppUser { Id = id, UserName = adminName }; _userServices.Setup(x => x.GetUsernameById(id)) .ReturnsAsync(admin.UserName); _userServices.Setup(x => x.GetAdmin()) .ReturnsAsync(admin); _iNotificationManager.Setup(x => x.BarAddedDescription(adminName, barName)) .Returns($"New Bar notification: User: {adminName}, just added new Bar with name: {barName}"); using (var arrangeContext = new CMContext(options)) { arrangeContext.Add(admin); await arrangeContext.SaveChangesAsync(); Assert.AreEqual(0, arrangeContext.Notifications.Count()); var sut = new NotificationServices(arrangeContext, _userServices.Object, _iNotificationManager.Object); await sut.BarCreateNotificationToAdminAsync(id, barName); Assert.AreEqual(1, arrangeContext.Notifications.Count()); } }
public HolidayServices(RealEstateDbContext dbContext , NotificationServices notificationServices , UserServices userServices) { this.dbContext = dbContext; this.notificationServices = notificationServices; this.userServices = userServices; }
/// <summary> /// Registruje aplikaciju za setovanje i primanje lokalnih notifikacija na IOS-u. /// </summary> public void RegisterForLocalNottifications() { #if UNITY_IOS && !UNITY_EDITOR //za tip notifikacije promeniti argument funkcije //ovo je default poziv NotificationServices.RegisterForNotifications(NotificationType.Alert | NotificationType.Badge | NotificationType.Sound); #endif }
public override void ResetBadgeNumber() { LocalNotification ntf = new LocalNotification(); ntf.fireDate = DateTime.Now.AddSeconds(1); ntf.applicationIconBadgeNumber = -1; NotificationServices.ScheduleLocalNotification(ntf); }
void Update() { foreach (var notification in NotificationServices.remoteNotifications) { HandleMessage(notification.userInfo); } NotificationServices.ClearRemoteNotifications(); }
/// <summary> /// Clears all of the created Local Notifications wherever they're showed or are still waiting to be triggered /// </summary> public static void ClearLocalNotifications() { #if UNITY_IOS NotificationServices.ClearLocalNotifications(); NotificationServices.CancelAllLocalNotifications(); #elif UNITY_ANDROID #endif }
private string PostContent(string username, string password, ref Post post, bool publish, PostType postType) { ValidateUser(username, password, Blog.AllowServiceAccess); var entry = new Entry(postType) { PostType = postType, IsActive = publish, Author = Blog.Author, Email = Blog.Email }; post.CopyValuesTo(entry); entry.AllowComments = true; entry.DisplayOnHomePage = true; DateTime dateTimeInPost = post.dateCreated != null ? post.dateCreated.Value : DateTime.UtcNow; // Store in the blog's timezone dateTimeInPost = Blog.TimeZone.FromUtc(dateTimeInPost); entry.DateCreated = entry.DateModified = Blog.TimeZone.Now; if (publish) { entry.DateSyndicated = dateTimeInPost; } entry.IncludeInMainSyndication = true; entry.IsAggregated = true; entry.SyndicateDescriptionOnly = false; int postId; try { //TODO: Review whether keywords should be true. postId = EntryPublisher.Publish(entry); if (Blog.TrackbacksEnabled) { NotificationServices.Run(entry, Blog, Url); } if (post.enclosure != null) { Components.Enclosure enclosure = post.enclosure.Value.CopyValuesToEnclosure(); enclosure.EntryId = postId; Repository.Create(enclosure); } AddCommunityCredits(entry); } catch (Exception e) { throw new XmlRpcFaultException(0, e.Message + " " + e.StackTrace); } if (postId < 0) { throw new XmlRpcFaultException(0, Resources.XmlRpcFault_AddPostFailed); } return(postId.ToString(CultureInfo.InvariantCulture)); }