/// <summary> /// Constructor /// </summary> public FCMPushNotificationService(IOptions <PushNotificationServiceOptions> options, NotifServerDbContext db) { if (string.IsNullOrWhiteSpace(options.Value.FCMServerToken)) { throw new Exception("FCM Server Key is required"); } FCMServerToken = options.Value.FCMServerToken; _db = db; _Http = new HttpClient { BaseAddress = new Uri("https://fcm.googleapis.com/fcm/") }; _Http.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", $"key={FCMServerToken}"); }
private NotifServerDbContext GetContextWithData() { var options = new DbContextOptionsBuilder <NotifServerDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var context = new NotifServerDbContext(options); var user = new UserInfo { UserId = "", Token = "", Platform = DevicePlatform.iOS }; context.UserDeviceTokens.Add(user); context.SaveChanges(); return(context); }