<?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 Alexi Christakis on Medium]]></title>
        <description><![CDATA[Stories by Alexi Christakis on Medium]]></description>
        <link>https://medium.com/@alexi.christakis?source=rss-27c5ee094ca9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*kbI5rMYrmEXLm5PO.</url>
            <title>Stories by Alexi Christakis on Medium</title>
            <link>https://medium.com/@alexi.christakis?source=rss-27c5ee094ca9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 19:23:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alexi.christakis/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[Screen Time is the greatest recent product that Apple has released]]></title>
            <link>https://medium.com/@alexi.christakis/screen-time-is-the-greatest-recent-product-that-apple-has-released-2671639f0cc?source=rss-27c5ee094ca9------2</link>
            <guid isPermaLink="false">https://medium.com/p/2671639f0cc</guid>
            <category><![CDATA[iphone]]></category>
            <category><![CDATA[screentime]]></category>
            <category><![CDATA[overstimulation]]></category>
            <category><![CDATA[addiction]]></category>
            <category><![CDATA[apple]]></category>
            <dc:creator><![CDATA[Alexi Christakis]]></dc:creator>
            <pubDate>Sat, 05 Oct 2019 21:20:42 GMT</pubDate>
            <atom:updated>2019-10-06T20:28:19.933Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://screentime-525d7.firebaseapp.com/">https://screentime-525d7.firebaseapp.com</a></p><p>With the release of iOS v12.0 in 2018, a new page appeared in the settings app. Screen Time: a feature that allows users to track their usage with great granularity. For the first time, iPhone users have a native solution to visualize and learn about their phone usage, and to cut back.</p><p>At the top of the Screen Time page, a stacked bar graph shows how much time has been spent either over the course of a week, with time in app categories aggregated by day, or the time spent in a single day with time aggregated by hour. Daily averages are shown in both views, with weekly trends highlighted (as a percent change). Most used apps or app categories are listed by decreasing time beneath the chart. Tapping an individual entry shows how its usage is distributed.</p><p>Beneath the time section, two graphs — of pickups and notifications — are shown. Each of these sections also has information about which apps are involved. For pickups, this is shown as which apps most commonly immediately follow the phone’s unlock. For notifications, a breakdown of how many notifications are received from each app. While typically conversations around phone usage focus on overall screen time usage in a given day or week, the number of pickups and notifications provide important metrics to learn about how frequently our days are interrupted, and by what. Knowing which apps are the biggest culprits is helpful when working to cutdown usage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EkeRsjJV7TeAdEr41BUsmw.png" /><figcaption>my own Screen Time data</figcaption></figure><p>Surprisingly, Apple also includes a suite of tools for managing and restricting how you’re allowed to use different apps. Users are able to set “Downtimes” where apps or categories are disabled during certain periods of the day; “App Limits” to restrict apps or app categories above a certain usage threshold; “Content &amp; Privacy” rules to prevent apps from collecting certain types of user data, or from displaying type of content to a user; and “Always Allowed” app whitelists to permit their usage regardless of what other rules might be set.</p><p>This inclusion is refreshing because it directly conflicts with one of the purported goals of the iPhone: to keep users engaged as much as possible. Apple recognizes that phone addiction is a serious and rapidly growing problem, and that their products might be engineered so well that users have trouble staying connected to “real” life.</p><p>“A 2011 university study suggested people check their phones thirty-four times per day. However, industry insiders believe that number is closer to an astounding 150 daily sessions.” (Nir Eyal, Hooked 2014).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oAvthPc3pNvxZey4eI4QuQ.png" /></figure><p>Even if 150 daily sessions is an over-estimate, other studies suggesting the number is between 52 and 80. Trends also suggest that our usage has only continued to increase, and other studies on phone addiction show our adherence to smart phones is indelible. In 2011, TeleNav conducted a survey that revealed 33% of respondents would rather give up sex than their phones, and perhaps even more surprisingly, 21% would give up shoes.</p><p>Ironically, I’m obsessed with Screen Time because Apple has taken a surprising stance in the war against digital devices, by practically encouraging its users to use iPhones and iPads less by surfacing detailed metrics, and providing a powerful toolkit to set limits. It’s no secret that people are using digital devices at increasing rates and amounts. In 2015, a study conducted by Common Sense Media found the average teenager in the U.S. spent nine hours per day across their digital devices.</p><p>My recommendations for the product’s future revolve primarily around the data’s visualization. Including the pickups and notifications provides valuable insight into how a day is segmented into phone sessions, but by altering the main display to account for this, the data would be easier to interpret. On the same note, discovering what our phones most often interrupt is an important part of the story that is currently unknowable.</p><p>I think the most important aspect of our phone usage (which is often under-discussed) is the way in which we’re distracted and interrupted. Spending multiple hours a day on a device can be extremely productive, and not necessarily detract from one’s attentiveness. The definition of “screen time” is enormously broad, and with the proliferation of digital devices in the 21st century, it’s nearly impossible to do productive work without one. Even when examining an individual’s online usage it’s hard to grossly label it all as negative. Obviously not all screen time is “bad”, and the breakdown given by Screen Time by app category is helpful in diagnosing how a user may fall on the spectrum from meaningless time wasting (via social media, games, etc.) to what is considered more “thoughtful” content consumption (news reading, google searches, email sending etc.). But even the category of social media can’t entirely be spun with a negative valence. The original goal of social platforms was to connect humans with each other, and truly no products are more effective at doing so than apps like Facebook and Instagram. They also provide havens for those experiencing difficulties outside of the digital realm. Countless communities exist across forums like Reddit, Groups (from Facebook), and others, that provide unquantifiable support.</p><p>Yet at the same time, 3 hours of phone usage divided across 200 pickups is less than one minute spent per phone session on average. Even if those 3 hours are all in a category or usage undeniably “positive,” when it’s partitioned into micro-sessions it cannot provide the same value as fewer longer sessions, and still disrupts interactions in the physical world. While it’s easy to feel good learning that you spend an average of 1.5 hours on “Reading &amp; Reference” a day — a category associated with news apps — if the average length of each session isn’t enough to read a single article the meaning of the time has to be reconsidered. My inspiration for this project came from these alternative considerations of our usage sessions, and how there’s more to the story of phone addiction that a single metric of hours in a day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nIfg4FSRjajvqCaz7Bi0eA.png" /><figcaption>my visualization, powered by React and p5.js</figcaption></figure><p>Through exploring other possibilities for the visualization provided by Screen Time, I developed my own product for digesting the data. It builds on the idea of centering the discussion around the number of pickups a user has by distributing screen time usage and notifications amongst pickups as a way to emulate phone sessions. Each pickup is to serve a purpose: to check an email, read text messages, browse Facebook, read an article etc., and is prompted by some number of notifications calling for the user’s attention. Therefore it’s interesting to represent screen time usage around this premise of usage sessions, where the density of time spent in each app category can be explored across phone pickups. It’s also important to note that a pickup is defined by any trigger to turn the display on, and thus doesn’t have to go beyond the phone’s lock-screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nnPqrWaVzyQJA8ESBBHhqQ.jpeg" /></figure><p>Apple’s solution does provide some insight into how usage is distributed across a day, but aggregating minutes around the pickups that trigger them gives a clearer picture.</p><p>In my generative art visualization, each pickup, each notification, and quantity of minutes are represented as dots (all color-coded by their type). To represent the various types of phone sessions, notifications and time are attracted to pickups. They’re distributed randomly across the pickups, and then rendered as independent simulations on the same canvas. Each phone session becomes a small cluster of dots with a single pickup. The animation is timed so that the a single session is added at a time, with its dots spread randomly across the whole display, resulting in a series of particles quickly clustering and organizing out of the initial chaos.</p><p>While it provides a somewhat interesting complement to the visualizations provided by Apple, it’s more of a suggestion as to how insight could be drawn from Screen Time data. My algorithm to distribute minutes from each category between pickups is random, and could easily misrepresent what the user’s patterns actually are. In terms of extensions to this project, I’d like to build more validations into the form to ensure realistic values are entered, and try to visualize what screen time averages are. I see other challenges to this as well, as apart from simple validations there’s no way to reliably detect what truthful data is. While it would increase the value of the tool to see how your own data compares to the average, from my own tests of the product users have a lot of fun entering random values to see how the visualization changes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2671639f0cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native Push Notifications with Firebase Cloud Functions]]></title>
            <link>https://medium.com/yale-sandbox/react-native-push-notifications-with-firebase-cloud-functions-74b832d45386?source=rss-27c5ee094ca9------2</link>
            <guid isPermaLink="false">https://medium.com/p/74b832d45386</guid>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Alexi Christakis]]></dc:creator>
            <pubDate>Thu, 30 Nov 2017 05:09:36 GMT</pubDate>
            <atom:updated>2018-09-04T16:19:03.190Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N03PRdPT6M77xhuRQWXBLA.png" /><figcaption>success!!</figcaption></figure><p>Google’s new Cloud Functions service for Firebase is a huge addition to their offerings, and I’ve been focused on utilizing it for one feature in particular: serverless push notifications. I started working on a basic social networking app a few weeks ago, and from the onset implementing notifications was a definitive goal (quite honestly it was the purpose of the project). However, I did not want to go through the trouble of setting up a server in order to listen to my Firebase data. Luckily for me, with some basic knowledge of how to use Firebase SDKs, push notifications became quick and easy.</p><p>Setting up push notifications — even with this implementation — can be daunting, especially given the amount of set-up that is required. To follow my implementation, three Firebase services must be utilized:</p><ol><li><strong>Firebase Authentication </strong>(technically optional)</li><li><strong>Firestore or Realtime Database</strong></li><li><strong>Firebase Cloud Messaging (FCM)</strong></li><li><strong>Firebase Cloud Functions</strong></li></ol><h3><strong>Setting Up Firebase with RNF:</strong></h3><p>Unfortunately, Google’s documentation for React Native users is fairly limited, and even the most popular integration packages skimp on thorough instructions, and have inconsistent features. I opted to use <a href="http://rnfirebase.io/">React Native Firebase (RNF)</a>. Luckily, their installation procedure is straightforward and well described.</p><p>Install node module, then link the dependency.</p><pre>$ npm install --save react-native-firebase</pre><pre>$ react-native link react-native-firebase</pre><p>Create a Firebase project in the console, download the GoogleService-Info.plist and move it to:<em> ios/[YOUR APP NAME]</em> so the SDK can connect to your project. Open the project with XCode to ensure the file has been added properly. If it doesn’t show up in the sidebar, just drag the file in.</p><p>Then, open AppDelegate.m and add:</p><pre>#import &lt;Firebase.h&gt;</pre><p>As well as:</p><pre>[FIRApp configure];</pre><p>at the beginning of the <em>didFinishLaunchingWithOptions:(NSDictionary * )launchOptions</em> method.</p><p><a href="https://guides.cocoapods.org/using/getting-started.html#getting-started">Set up CocoaPods.</a></p><p><a href="https://firebase.google.com/docs/ios/setup#add_the_sdk">Generate a Podfile.</a></p><p>Sometimes the Podfile generates with duplicate declarations, copy and paste the following into yours if errors are reported:</p><pre># Uncomment the next line to define a global platform for your project<br>platform :ios, &#39;9.0&#39;</pre><pre>target &#39;[YOUR APP NAME]&#39; do<br>  # Uncomment the next line if you&#39;re using Swift or would like to use dynamic frameworks<br>  # use_frameworks!</pre><pre># Pods for Sesh<br>  pod &#39;Firebase/Core&#39;<br>  pod &#39;Firebase/Firestore&#39;<br>  pod &#39;Firebase/Messaging&#39;</pre><pre>target &#39;Sesh-tvOSTests&#39; do<br>    inherit! :search_paths<br>    # Pods for testing<br>  end</pre><pre>target &#39;SeshTests&#39; do<br>    inherit! :search_paths<br>    # Pods for testing<br>  end</pre><pre>end</pre><p>Run:</p><pre>$ pod install</pre><p>If any issues are encountered, refer to <a href="https://rnfirebase.io/docs/v3.1.*/installation/ios">here</a>.</p><p>I’m going to assume you already have a working application built with a backend database to save time — don’t worry, there are plenty of guides on how to do this, check out the docs <a href="https://firebase.google.com/docs/firestore/">here</a>. At the very least, for directed push notifications, your database must store unique push tokens for each user, and presumably some data to send them.</p><h3><strong>Firebase Cloud Messaging:</strong></h3><p>First, in Xcode, add the following to AppDelegate.h:</p><pre>@import UserNotifications;<br><br>// change this with extra parameter<br>@interface AppDelegate : UIResponder &lt;UIApplicationDelegate,UNUserNotificationCenterDelegate&gt;</pre><p>And the following to AppDelegate.m:</p><pre>#import &quot;RNFIRMessaging.h&quot;</pre><pre>// add before return YES;<br>  [FIRApp configure];<br>  [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];<br>  <br>// add before @end<br>- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler<br>{<br>  [RNFIRMessaging willPresentNotification:notification withCompletionHandler:completionHandler];<br> }<br><br>- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler<br>{<br>     [RNFIRMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler];<br>}<br><br>- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{<br>   [RNFIRMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];<br>}</pre><p>You will also need to enable the capabilities Push Notifications, and Remote Notifications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J_2FI5oejEExhI0G6sQBgg.png" /></figure><p>To set up FCM with RNF, there are two functions that you must call after user authentication. The first is to request permissions from the user, and the second is to get the device’s unique push notification token, which returns a promise with the token. This needs to be stored somewhere in your database; I opted for the user’s document under the collection “users”. See below:</p><pre>FCM = firebase.messaging();<br>ref = firebase.firestore().collection(&quot;users&quot;);</pre><pre>// check to make sure the user is authenticated  <br>firebase.auth().onAuthStateChanged(user =&gt; {</pre><pre>  // requests permissions from the user<br>  FCM.requestPermissions();</pre><pre>  // gets the device&#39;s push token<br>  FCM.getToken().then(token =&gt; {<br>   <br>   // stores the token in the user&#39;s document<br>   this.ref.doc(user.uid).update({ pushToken: token });<br>  });<br>  <br>});</pre><p>That gives the client <em>basic</em> FCM functionality. There’s a lot more that can be done with the SDK, and I encourage further reading so that your push notifications become more interactive. On the Firebase side, a permission key must be supplied to the console so that Google’s servers are able to connect with APNS. This key is easily generated through Apple’s developer tools. <a href="https://firebase.google.com/docs/cloud-messaging/ios/certs">Check out Google’s guide.</a></p><p>Test to make sure FCM is working by sending a notification from the Firebase console. You will need to install the release scheme of your application on a real device; the simulators don’t support APNS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q0SgiFQhrYE73SDKu_EItw.png" /><figcaption>even if the console reports the status as completed the message may have failed</figcaption></figure><p>Debugging:</p><ul><li>Make sure that the bundle identifier of your application matches that of the Firebase application, and the generated key.</li><li>Make sure your application requested notification permissions upon first launch.</li><li>Check your database to see if a token was properly generated and stored.</li></ul><h3><strong>Firebase Cloud Functions:</strong></h3><p>Once FCM is working, the final step is to write a cloud function to listen for database activity — this is the coolest part. To start, install the Firebase CLI and login.</p><pre>$ npm install -g firebase-tools<br>$ firebase login</pre><p>Then cd into your project directory and run:</p><pre>$ firebase init</pre><p>When it prompts you to install node modules return yes. Once the script completes, in your React Native project you should now have a new folder: functions. Open the index.js file and begin <a href="https://firebase.google.com/docs/functions/firestore-events">writing functions</a>!</p><p>To start, two dependencies have to be imported:</p><pre>import functions from &quot;firebase-functions&quot;;<br>import admin from &quot;firebase-admin&quot;;</pre><pre>// initializes your application<br>admin.initializeApp(functions.config().firebase);</pre><p>Since this function will be running on Google’s servers, you have access to all Firebase services.</p><p>Make sure to export any function that you want Google to upload, but feel free to write auxiliary functions that aren’t exported.</p><pre>exports.sendPushNotification = functions.firestore<br>  .document(&quot;some_collection/{some_document}&quot;)<br>  .onCreate(event =&gt; {</pre><pre>    // gets standard JavaScript object from the new write<br>    const writeData = event.data.data();</pre><pre>    // access data necessary for push notification <br>    const sender = writeData.uid;<br>    const senderName = writeData.name;<br>    const recipient = writeData.recipient;</pre><pre>    // the payload is what will be delivered to the device(s)<br>    let payload = {<br>      notification: {<br>      title: <br>      body:<br>      sound:<br>      badge:<br>     }<br>    }</pre><pre>    // either store the recepient tokens in the document write<br>    const tokens = writeData.tokens;  </pre><pre>    <br>    // or collect them by accessing your database<br>    var pushToken = &quot;&quot;;</pre><pre>    return functions<br>      .firestore<br>      .collection(&quot;user_data_collection/recipient&quot;)<br>      .get()<br>      .then(doc =&gt; {<br>         pushToken = doc.data().token;</pre><pre>         // sendToDevice can also accept an array of push tokens<br>         return admin.messaging().sendToDevice(pushToken, payload);</pre><pre>      });<br>});</pre><p>Key things to note:</p><ol><li>Escaping tags in your database path institutes multiple listeners. For example: “posts/{userID}/statuses/{statusID}” listens to the status collections of <em>every </em>user, and triggers the function if documents are changed in any one of them. You can then access userID and statusID within your function as variables.</li><li>Be sure to return functions you want Firebase to execute.</li></ol><p>Once the function is complete:</p><pre>$ cd /yourprojectdirectory/<br>$ firebase deploy</pre><p>This uploads your function to Google’s servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qNQHtKrPlmvEpH2gHx05DQ.png" /><figcaption>if it doesn’t show up right away, try refreshing</figcaption></figure><p>Also, check the logs! The Cloud Functions pane provides detailed error reports:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jkSuw-3Ht2RxwqLmeWapEA.png" /><figcaption>I had issues retrieving push tokens at first</figcaption></figure><p>Once it uploads without errors, try performing a write operation to the node in your database that the function is listening to, either manually or by using a simulator. If the notification doesn’t come through at first, check the logs again to make sure it’s executing properly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rFt7USIwSmLd20zNuMKj_g.png" /></figure><p>If a notification appears on your device congrats! Now it’s easy to expand the feature by writing more Cloud Functions, and to implement it in other projects.</p><p>I’ll try to throw together an example/starter app for this and will link it here when it’s ready. In the meantime, I’ll do my best to respond to issues below.</p><p>more guides:</p><ul><li><a href="https://school.shoutem.com/lectures/react-native-chat-app-serverless-firebase-push-notifications/">https://school.shoutem.com/lectures/react-native-chat-app-serverless-firebase-push-notifications/</a></li><li><a href="https://aaronczichon.de/2017/03/13/firebase-cloud-functions/">https://aaronczichon.de/2017/03/13/firebase-cloud-functions/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74b832d45386" width="1" height="1" alt=""><hr><p><a href="https://medium.com/yale-sandbox/react-native-push-notifications-with-firebase-cloud-functions-74b832d45386">React Native Push Notifications with Firebase Cloud Functions</a> was originally published in <a href="https://medium.com/yale-sandbox">sandbox</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>