<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nick Culpin on Medium]]></title>
        <description><![CDATA[Stories by Nick Culpin on Medium]]></description>
        <link>https://medium.com/@nickculpin?source=rss-f41c80380af5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*sI_TPC7WVo633Tt5SzOXSw.jpeg</url>
            <title>Stories by Nick Culpin on Medium</title>
            <link>https://medium.com/@nickculpin?source=rss-f41c80380af5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 13:19:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nickculpin/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to perform cross-platform receipt verification using Firebase Cloud Functions]]></title>
            <link>https://medium.com/travelear/how-to-perform-cross-platform-receipt-verification-using-firebase-cloud-functions-230511a0b007?source=rss-f41c80380af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/230511a0b007</guid>
            <category><![CDATA[cloud-functions]]></category>
            <category><![CDATA[in-app-purchase]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Nick Culpin]]></dc:creator>
            <pubDate>Thu, 28 May 2020 18:20:47 GMT</pubDate>
            <atom:updated>2020-05-28T20:25:14.372Z</atom:updated>
            <content:encoded><![CDATA[<h3>Perform receipt verification using Firebase Cloud Functions</h3><p>Using Firebase Cloud Functions we’ll verify Stripe &amp; Apple renewable subscriptions with webhooks.</p><h3>Travelear, Inc. provides high-quality binaural audio recordings created with the intention of transporting you to real locations from all over the world. You can download it from the app store right now by clicking the link below:</h3><p><a href="https://apps.apple.com/us/app/travelear-listen-to-the-world/id1159408401">https://apps.apple.com/us/app/dreamear-sleep-relax-focus/id1473473909</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_H6IFohUqUL5MqMiRngOww.png" /></figure><h3>Our Task</h3><p>Create a series of cloud functions that handle webhook receipt validations for Apple &amp; Stripe based subscriptions.</p><h3>Our Plan</h3><ol><li>Function Setup</li><li>Event Listeners</li><li>Update</li><li>Client Requests</li></ol><h3>Our Solution</h3><h4>Step 1. Function Setup</h4><p>We can keep our code clean by separating our cloud functions into a separate backend repository. I’d suggest you do the same by following the instructions to generate a new Firebase project and initialize only what you need in any given project. In this case, we only care about functions.</p><pre>npm install -g firebase-tools<br>firebase login<br>firebase init functions</pre><p>You can read more about this over in the Firebase documentation <a href="https://firebase.google.com/docs/functions/get-started">https://firebase.google.com/docs/functions/get-started</a></p><p>Once you load your project you can see an index.js which we’ll want to exit as quickly as possible. As you work you’ll quickly realize that this file can get pretty cumbersome, so what I like to do is move my functions into a source directory and simply use the index as a reference. So your new structure should look like the following.</p><pre>myproject<br> +- .firebaserc                <br> |<br> +- firebase.json<br> |<br> +- functions/<br>      |<br>      +- src/<br>            apple.js # Contains functions for Apple<br>            stripe.js # Contains functions for Stripe<br>      |<br>      +- .eslintrc.json<br>      |<br>      +- package.json<br>      |<br>      +- index.js      # Reference to ./src files<br>      |<br>      +- node_modules/</pre><p>Inside your index.js you’ll set up some on request and on write functions which will then be forward to your src files like this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0995f2e6c3720b654b6626cdc578caeb/href">https://medium.com/media/0995f2e6c3720b654b6626cdc578caeb/href</a></iframe><h4>Step 2. Listen</h4><p>For our listeners, we’ll use a helper package called request-promise:<br><a href="https://www.npmjs.com/package/request-promise">https://www.npmjs.com/package/request-promise</a></p><pre>npm i request-promise</pre><p>This will help us return a response to our webhook when we validate with Apple or Stripe.</p><p>Heading over to src/apple.js, well structure our listener for an apple subscription webhook.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf4d2386183712582be19a7eb56758d6/href">https://medium.com/media/cf4d2386183712582be19a7eb56758d6/href</a></iframe><h4>Step 3. Update</h4><p>Once we have written and stored the receipt change for the user, we’ll need to update the user&#39;s data. We’ll update records for the date of the change, the status of the subscription, and where it came from.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b05acac7c190b8ef8238223b5cc9671/href">https://medium.com/media/0b05acac7c190b8ef8238223b5cc9671/href</a></iframe><h4>Step 3. Client Request</h4><p>If you want to have the client request a validation directly from your app, you’ll still need a cloud function to make this transaction. This is helpful if you want to verify the first purchase and provide content immediately after and not wait for a transaction event to post. Apple discourages direct calls to their receipt validation service from the client for security.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85f81cad240be445c2af6fb3d42eea27/href">https://medium.com/media/85f81cad240be445c2af6fb3d42eea27/href</a></iframe><p>You’ll notice in the above example the line,</p><pre>var secret = functions.config().apple.secret;</pre><p>In order to get, post, and delete Firebase env variables, you can use the following commands.</p><p>Set Data:</p><pre>Firebase functions:config:set category.key=value</pre><pre>example:<br>Firebase functions:config:set gmail.log=yourlogin@gamail.com gmail.password=yourpass</pre><p>Get Data:</p><pre>Firebase functions:config:get</pre><p>Delete Data:</p><pre>Firebase functions:config:unset category</pre><pre>example:<br>Firebase functions:config:unset gmail</pre><p>Finally, we can move on to our Stripe validations, which you can see are nearly identical except for the headers in the request, and the response secrets.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a3bee2e3f943fa6a20ddf00894bff4e0/href">https://medium.com/media/a3bee2e3f943fa6a20ddf00894bff4e0/href</a></iframe><p>finally….</p><pre>firebase deploy</pre><p>Further reading…</p><p>Firebase has more code examples for Stripe integrations in their Github repo: <br><a href="https://github.com/firebase/functions-samples/tree/master/stripe">https://github.com/firebase/functions-samples/tree/master/stripe</a></p><p>Thanks for reading!</p><p><strong>Travelear, Inc</strong><br><a href="https://www.thetravelear.com/">https://www.thetravelear.com/</a></p><p><strong>Dreamear: Sleep, Relax Focus</strong><br><a href="https://apps.apple.com/us/app/dreamear-sleep-relax-focus/id1473473909">https://apps.apple.com/us/app/dreamear-sleep-relax-focus/id1473473909</a></p><p><strong>Travelear: Listen to the World</strong><br><a href="https://apps.apple.com/us/app/travelear-listen-to-the-world/id1159408401">https://apps.apple.com/us/app/travelear-listen-to-the-world/id1159408401</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=230511a0b007" width="1" height="1" alt=""><hr><p><a href="https://medium.com/travelear/how-to-perform-cross-platform-receipt-verification-using-firebase-cloud-functions-230511a0b007">How to perform cross-platform receipt verification using Firebase Cloud Functions</a> was originally published in <a href="https://medium.com/travelear">Travelear</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streaming Audio Player in iOS]]></title>
            <link>https://medium.com/travelear/streaming-audio-player-in-ios-892601c0cbfd?source=rss-f41c80380af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/892601c0cbfd</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[3d-audio]]></category>
            <dc:creator><![CDATA[Nick Culpin]]></dc:creator>
            <pubDate>Thu, 28 May 2020 04:01:11 GMT</pubDate>
            <atom:updated>2020-05-28T04:06:10.204Z</atom:updated>
            <content:encoded><![CDATA[<h4>AVPlayerLooper, AVQueuePlayer plus zero-crossing audio files to achieve seamless audio looping with user-defined end time.</h4><h4>Dreamear provides high-quality binaural audio recordings created with the intention of helping you sleep, relax, or focus. You can download it from the app store right now by clicking the link below:</h4><p><a href="https://apps.apple.com/us/app/dreamear-sleep-relax-focus/id1473473909">https://apps.apple.com/us/app/dreamear-sleep-relax-focus/id1473473909</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jQ70EGlDZSARhoWFqWxWZQ.png" /><figcaption>Photo by Anthony Mehan <a href="https://www.anthonymehan.com/">https://www.anthonymehan.com/</a></figcaption></figure><h3>Our Task</h3><p>We should create a player service within our iOS application that will loop an audio file of an unknown source duration. We will take into account that the user will be using this to sleep or relax, the playback shouldn’t hard stop but rather a gradual reduction in volume as the user’s specified time gets closer.</p><h3>Our Plan</h3><ol><li>Load File</li><li>Play Audio</li><li>Timers and Observers</li><li>Pause &amp; Stop</li><li>Audio Files</li></ol><h3>Our Solution</h3><h4>Step 1. Load File</h4><p>We don&#39;t know where the file will be coming from, it may be that we are streaming but if the user has subscribed we will need to check if the file is local or not. We do this with a local store manager. Luckily, iOS has some helper methods to find this information about our application files but we can wrap them up nicely in a helper class. At this point, all we’ll need to do is call our class and pass it a file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c62e3348351818770cae139e88cd6ca5/href">https://medium.com/media/c62e3348351818770cae139e88cd6ca5/href</a></iframe><p>If we are streaming, we will need to make sure that we are connected to the internet so we’ll use another helper file to do that.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3e798c5bbc7d0f27b2f595e4cdb30f7/href">https://medium.com/media/c3e798c5bbc7d0f27b2f595e4cdb30f7/href</a></iframe><p>Now that we have those two helper files we can go ahead and load our files into our player. We really just need a file here but we wanted to allow our player to decide if it should preload in a paused or playing state.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a93be4e43da976310403eb45d7926a94/href">https://medium.com/media/a93be4e43da976310403eb45d7926a94/href</a></iframe><h4>Step 2. Play</h4><p>After we have populated our variables we can go ahead and load it into the player and begin playing the file. We async load this on the main queue and check for a file duration prior to playing the file then add our appropriate time observers.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8ab7ab6c8262344801d4d03bde486e9/href">https://medium.com/media/f8ab7ab6c8262344801d4d03bde486e9/href</a></iframe><h4>Step 3. Timers and Observers</h4><p>When a player is initialized, we add a time observer to it. From here, we update UI and check various user states based on that time. In Dreamear, we offered subscriptions, so this would be a good place to present the user with an upgrade pop over.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e9ca22bc64d2e19528feab7150c8a55/href">https://medium.com/media/0e9ca22bc64d2e19528feab7150c8a55/href</a></iframe><p>When a user selects a time to end playback we need to observe two timers. One to begin the volume reduction and the second to stop the player and remove the observers.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1154d3b71c7ba65c97e9a266226dfd45/href">https://medium.com/media/1154d3b71c7ba65c97e9a266226dfd45/href</a></iframe><h4>Step 4. Pause or Stop</h4><p>When the user decides to stop the player, we invalidate all of our time observers and timers as well as clear the player from data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f0ea9e486cd7adadf7325ed2cd9b301/href">https://medium.com/media/1f0ea9e486cd7adadf7325ed2cd9b301/href</a></iframe><p>Putting this all together here is the final file<br><a href="https://gist.github.com/njculpin/3fc2b7f83921b7de124762d62a255278">https://gist.github.com/njculpin/3fc2b7f83921b7de124762d62a255278</a></p><h4>Step 5. Audio Files</h4><p>One step that took us a while and probably the largest of our “Ah-HA!” moments were related to the audio files and how they would be constructed.</p><p>Garett, the lead Audio Engineer here at Travelear, Inc had decided that we should apply zero-crossing to both the beginning and end of the file and export it as a .wav file format. Wav files can be fairly large and not streaming friendly so in the post, we convert the file to an AAC file to help prevent data loss and allow the file to stream efficiently. Prior to this discovery, our files would pop when transitioning to the next player within the player queue. This was a result of standard mp3 files having dynamic timing and we couldn&#39;t accurately time transitions.</p><p>I hope this helps some of you with your audio playback projects. Be sure to check out our apps and let us know what you think!</p><p><strong>Travelear, Inc</strong><br><a href="https://www.thetravelear.com/">https://www.thetravelear.com/</a></p><p><strong>Dreamear: Sleep, Relax Focus</strong><br><a href="https://apps.apple.com/us/app/dreamear-sleep-relax-focus/id1473473909">https://apps.apple.com/us/app/dreamear-sleep-relax-focus/id1473473909</a></p><p><strong>Travelear: Listen to the World</strong><br><a href="https://apps.apple.com/us/app/travelear-listen-to-the-world/id1159408401">https://apps.apple.com/us/app/travelear-listen-to-the-world/id1159408401</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=892601c0cbfd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/travelear/streaming-audio-player-in-ios-892601c0cbfd">Streaming Audio Player in iOS</a> was originally published in <a href="https://medium.com/travelear">Travelear</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>