Swift In App Subscription How to check active status? - ios

This question might have been asked but I did not find a good solution for me.
So: If I want to check if a user is subscribed in my app for a week or month, is there a specific value that says "active" true / false OR do I have to calculate it in code by checking the current timestamp with the start of subscription?
Like: `currentDate - dateSubscribed = daysRemaining
I saw codesampes but I could not determine it from the samples.

Almost. You should check against the expiration_date field and compare that against the current date.
Ideally, you compare the date against a server time instead of the device time which the user can easily change.
If you want a deeper read of checking subscription status for users check out: iOS Subscriptions are Hard

Related

Can we set price different for the first year and onward? Like, for first year 2.99 and then 0.99Subscription

Can we set price different for the first year and onward? Like, for first year 2.99 and then 0.99
Yes you can! You can set up a Pay-up-Front Introductory price: SKProductDiscountPaymentModePayUpFront
This is set up completely in App Store Connect when configuring your product.
See more about the different types of introductory prices: iOS Introductory Prices
There might not be an out of the box solution for this.
But maybe you can try something like this.
Create 2 price points 2.99/year and .99/year
When the user opens the page, check to see if they've previously bought a subscription, if they have, hide the 2.99/year and show the .99/year
If they haven't bought previously, then only show 2.99/year and on a successful purchase, keep a record of it on your backend server.

Show active record object to user based on time elapsed

I have this application which general goal is to poll users, aggregate their responses and create pie/bar charts.
My objective is while creating the questions set a time that will define when they are available for the users to see them and therefore answer to them.
What's the best approach to implement something like this? Maybe a background job that will automatically present the questions to the users or, probably when the users refresh the page where the questions should appear verify the elapsed time and present only the questions that are available in that day?
Use case: create a question that will be available tomorrow at 12h and will end at 13h.
Thanks
You can just use SQL.
scope :available, -> { where('start_date >= :time AND end_date <= :time', time: Time.current) }
and then use it in controller or where you want to.
You have good explanation here date scopes

How to add Data to Firebase?

My goal is to add +1 every day to a global variable in Firebase to track how many days have passed. I'm building an app that give new facts every day, and at the 19:00 UTC time marker, I want the case statement number (the day global day variable) to increment by +1.
Some have suggested that I compare two dates and get the days that have passed that way. If I were to do that, I could hard code the initial time when I first want the app to start at 19:00 some day. Then when the function reached1900UTC() is called everyday thereafter, compare it to a Firebase timestamp of that current time which should be 19:00. In theory, it should show that 1 day or more day has passed.
This is the best solution so far, thanks to #DavidSeek and #Jay, but I would still like to figure it out with concurrent writes if anyone has a solution in that front. Until then, I'm marking David's answer as the correct one.
How would I make it so it can't increase more than +1 if multiple people call this? Because my fear is that, when say, 100 people calls this function, it increases by + 1 for every person that has called it.
My app works on a global time, and this function is called every day at 19:00 UTC. So when that function is called I want the day count to increase by one.
You should use transactions to handle concurrent writes:
https://firebase.google.com/docs/database/ios/read-and-write#save_data_as_transactions
You may know this but Firebase doesn't have a way to auto-increment a counter as there's no server side logic, so having a counter increment at 19:00 UTC isn't going to be possible without interaction from a client that happens to be logged on at that time.
That being said, it's fairly straightforward to have the first user that logs in increment that counter - then any other clients logging in after that would not increment it and would have access to that day's new content.
Take a look at Zapier.com - that's a service that can fire time based triggers for your app which may do the trick.
As of this writing, Zapier and Firebase don't play nice together, however, there are a number of other trigger options that Zapier can do with your app while continuing to use Firebase for storage.
One other thought...
Instead of dealing with counters and counting days, why not just have each day's content stored within a node for each day and when each user logs on, the app get's that days content:
2016-10-10
fact: "The Earth is an Oblate Spheroid"
2016-10-11
fact: "Milli Vanilli is neither a Milli or a Vanilli. Discuss."
2016-10-12
fact: "George Washington did not have a middle name"
This would eliminate a number of issues such as counters, updates, concurrent writing to Firebase, triggers etc.
It's also dynamic and expandable and a user could easily see that day's facts or the fact for any prior day(s)
I'm trying to split your question into different sections.
1) If you want to use a global variable to count the days from, let's say, today. Then I would set a timestamp hardcoded into the App that sets the NSDate.
Then In my App, when I need to know the days that have been passed by, I would call a function counting the days from the timestamp to NSDate().
2) If you have a function in your App that counts a +1 into a Firebase, then your fear is correct. It would count +1 for every person that uses the App.
3) If you want every User to have a variable count since when they use their App, then I would handle User registration. So I have a "UserID" and then I would set a Firebase tree like that:
UserID
------->
FirstOpen
-------> Date
That way you could handle each User's first open.
Then you are able to set a timestamp AND call +1 for every user independently. Because then you set the +1 for every user into their UserID .child

Dailymotion API - set publication date and end date of video

is there any possibility to set the release date and the end date of a video?
I cannot find any request to do this (start_date and end_date is not what I am searching for, because it is only for live-streams).
I know that it is possible to set those two parameters when you are accepted as official.
http://s14.directupload.net/images/141029/3msfkrvc.png
I want to set the three values in the second box which is possible if the video is marked as private and the account is official. Is it possible to set those values with a normal Request (e. g. something like https://api.dailymotion.com/video/VIDEOID?private=1&publication_start=...) or was this not implemented?
I mailed a bit with their support.
It is currently not possible / only possible for few people with special contracts but there is a chance that they will implement it soon.

Need a specific operation to be performed on Fogbugz api

I need to get some very specific information from the FogBugz API. Although I can spend time with the API documentation but I was just wondering if folks here had experience with it and might offer some help.
I need this information - for a given date range and a given person I want to know how much time he spent on the tickets.
So, we use the 'working on' feature a lot and I think we can get this info using this feature somehow. Not sure.
So what command/query should I be looking at?
Any suggestions/pointers would be helpful!
Thanks a bunch!
The FogBugz XML API can get you what you're looking for via the listIntervals command in the Time Tracking section:
cmd=listIntervals - returns all TimeIntervals for a user. Any of the optional arguments serve to filter the results.
Arguments
ixPerson (optional) - Specifies which user's intervals should be returned. If omitted, list intervals for the logged on user. If set
to 1, list intervals for all users. Note that you must be an
administrator to see time interval information for users other than
the logged on user.
ixBug (optional) - Specifies that only intervals associated with this bug should be returned.
dtStart, dtEnd (optional) - If dtStart and/or dtEnd are supplied, listIntervals will return intervals whose start date falls
between dtStart and dtEnd.
So the query you'd be using would look something like this:
[your FogBugz url]/api.asp?token=[your XML API token]&cmd=listIntervals&ixPerson=[ixPerson you're interested in]&dtStart=[start date]&dtEnd=[end date]
For future reference, there is a FogBugz-specific Q&A site: http://fogbugz.stackexchange.com

Resources