<?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 Ali Ozkara on Medium]]></title>
        <description><![CDATA[Stories by Ali Ozkara on Medium]]></description>
        <link>https://medium.com/@aliozkara?source=rss-d4f5238b7d82------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NP6sOme8x2w-9MsAKeLngA.jpeg</url>
            <title>Stories by Ali Ozkara on Medium</title>
            <link>https://medium.com/@aliozkara?source=rss-d4f5238b7d82------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 13:23:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aliozkara/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[Mac Application Distribution Outside AppStore (.PKG File)]]></title>
            <link>https://aliozkara.medium.com/mac-application-distribution-outside-appstore-pkg-file-8466cf1ae2c0?source=rss-d4f5238b7d82------2</link>
            <guid isPermaLink="false">https://medium.com/p/8466cf1ae2c0</guid>
            <category><![CDATA[pkg]]></category>
            <category><![CDATA[notarize]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[app-distribution]]></category>
            <category><![CDATA[mac]]></category>
            <dc:creator><![CDATA[Ali Ozkara]]></dc:creator>
            <pubDate>Tue, 21 Jan 2025 10:46:01 GMT</pubDate>
            <atom:updated>2025-01-21T10:46:01.798Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_SGS-ut6CBySq6vXAjQJOg.png" /></figure><p>When i need to distribute my Mac application outside the AppStore i realized that its complicated and painful for beginners so i decided to share this post step by step how to create your <strong><em>.pkg</em></strong> file and distribute your Mac app.</p><p><strong>First requirements before to start;</strong></p><p>Go to Apple Developer Account and create this certificates and provision profile file.<br><a href="https://developer.apple.com/account/resources/certificates/list"><em>https://developer.apple.com/account/resources/certificates/list</em></a></p><p><em>Developer ID Application.cer<br>Provisioning Profile.provisionprofile<br>Developer ID Installer.cer</em></p><p>I’ll not mention here how to create certificates i believe there are lots of content about that.</p><p>So you’re done development and ready to distribute your App.</p><p><strong>Code Signing</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fREmzK3m1x-YJdI8BW8iEA.png" /></figure><p>Choose <em>Developer ID Application </em>certificate and<em> Provisioning Profile </em>that you created with <em>Developer ID Application.</em></p><p><em>Hardened Runtime</em> enabled is a requirement for notarization.<br><a href="https://developer.apple.com/documentation/xcode/configuring-the-hardened-runtime"><em>https://developer.apple.com/documentation/xcode/configuring-the-hardened-runtime</em></a></p><p>You’re ready to get archive;</p><p><em>Xcode -&gt; Product -&gt; Archive</em></p><p>Choose your build and <strong><em>Distribute.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DtiFwgFfVwnUeH-rhwk54Q.png" /></figure><p><em>Custom -&gt; Direct Distrubition -&gt; Upload</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hpp6UNPBLV9CpXcUsPSHBA.png" /></figure><p>Choose same <em>Developer ID Application </em>certificate and<em> Provisioning Profile </em>that you created.</p><p>After upload you’ll wait a few minutes to Apple review and notarize your build.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q0y9Hv0ufI9S252P4-xMKA.png" /></figure><p><strong>Step 1:</strong></p><p>Once you export app, you’ll have <strong><em>.app</em></strong> file</p><p>Open terminal start with this command;</p><pre>productbuild — sign &lt;Identity&gt; — component &lt;PathToApp&gt; /Applications &lt;PathToPackage&gt;</pre><p>To find you &lt;Identity&gt; follow this command;</p><pre>security find-identity -v</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9HL_hLLl745V1ZZlUvLseQ.png" /></figure><p>Copy Developer Id Installer signing identity key and continue;</p><p>&lt;PathToApp&gt; is your .<strong>app</strong> file that you export from <em>Xcode</em> -&gt; <em>Organizer</em></p><pre>productbuild — sign &quot;7A2BC8F15D9E4R6M3N8P2Q9W7X5Y1Z4K6H8L3V9T&quot; — component YourApp.app /Applications YourApp.pkg</pre><p><em>/Applications</em> the location where your App will be installed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5woejnvYYIjy8-vocDFORw.png" /></figure><p><a href="https://developer.apple.com/documentation/xcode/packaging-mac-software-for-distribution"><em>https://developer.apple.com/documentation/xcode/packaging-mac-software-for-distribution</em></a></p><p>Now you’ll have <strong><em>.pkg</em></strong> file but this is not done yet.</p><p>We have to send <strong><em>.pkg</em></strong> file to Apple and notarize it.</p><p><strong>Step 2:</strong></p><p>To able to send .<strong><em>pkg </em></strong>file from command line we need <strong><em>App Specific Password</em></strong> its explain how to create it;<br><a href="https://support.apple.com/en-us/102654"><em>https://support.apple.com/en-us/102654</em></a></p><p>Run this command;</p><pre>xcrun notarytool store-credentials — apple-id “AppleId” — team-id “TeamId”</pre><p>Find your &lt;TeamId&gt;<br><a href="https://developer.apple.com/help/account/manage-your-team/locate-your-team-id/"><em>https://developer.apple.com/help/account/manage-your-team/locate-your-team-id/</em></a></p><p>Your developer account email&lt;AppleId&gt;</p><p><em>xcrun notarytool store-credentials — apple-id “</em><a href="/service/mailto:name@example.com"><em>name@example.com</em></a><em>” — team-id <br>“ABCD123456”</em></p><p>Don’t forget to <strong>Profile name</strong> that you specified.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x1mqBMaMoc1Gno2npRq_eg.png" /></figure><p><strong>Step 3:</strong></p><p>Now we are ready to send <strong><em>.pkg</em></strong> file to AppStore.</p><p>Follow this command;</p><pre>xcrun notarytool submit YourApp.pkg — keychain-profile “profilename” — wait</pre><p>This will take a few minutes to upload your build.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ARl3emePfcdwcytVkVX7hw.png" /></figure><p>Once you see <strong><em>Accepted</em></strong> its success.</p><p><strong>Last Step: Stapler</strong></p><p>Before distributing your .pkg installer, it’s highly recommended to perform a process called ‘stapling’. This process attaches the notarization ticket directly to your package by downloading it from Apple’s servers. While stapling isn’t mandatory, it significantly improves the end-user experience by eliminating the need for Gatekeeper to separately verify the notarization status online during installation. This means faster installation times and the ability to install even without an internet connection.</p><p><a href="https://support.apple.com/pl-pl/guide/security/sec5599b66df/web"><em>https://support.apple.com/pl-pl/guide/security/sec5599b66df/web</em></a></p><p>Follow this command;</p><pre>xcrun stapler staple YourApp.pkg</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c8JbW2MLHsq90bhjJO8ccg.png" /></figure><p>🎉 Finally your<strong><em> .pkg </em></strong>file ready to distribute.</p><p>Good Luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8466cf1ae2c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing the Network Layer in Flutter]]></title>
            <link>https://aliozkara.medium.com/implementing-the-network-layer-in-flutter-dcaf3d594c1e?source=rss-d4f5238b7d82------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcaf3d594c1e</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[network-layer]]></category>
            <category><![CDATA[http-request]]></category>
            <dc:creator><![CDATA[Ali Ozkara]]></dc:creator>
            <pubDate>Mon, 13 Mar 2023 16:09:58 GMT</pubDate>
            <atom:updated>2023-03-13T16:09:58.315Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Network Layer in Flutter" src="https://cdn-images-1.medium.com/max/1024/1*h4pm0KPLZxsOs-WfqAq4RA.jpeg" /></figure><p>One of the most critical aspects of any mobile application is networking, as most apps rely on communication with web services or APIs to fetch data and perform various actions.</p><p>In mobile projects, it’s common to use several different APIs to access data and functionality from remote servers. For example, an app might need to access a weather API to display current weather information, a social media API to retrieve user data, and a payment API to process transactions. To handle these various APIs in a flexible and extensible way, it’s important to have a well-designed network layer.</p><p>A good network layer should be extensible and flexible, allowing new APIs to be easily integrated into the project.</p><p>This can be achieved by using a modular architecture that separates the network layer into distinct components, such as request builders, response parsers, and error handlers. Each component can then be easily extended or replaced as needed to support new APIs or changes to existing APIs.</p><p><a href="https://github.com/aliozkara/NetworkLayerFlutter">GitHub - aliozkara/NetworkLayerFlutter: Extendable network layer for Flutter and sample app with MVVM</a></p><h4>Adding the http package to your project</h4><p>Before we can use the http package in our app, we need to add it to our project&#39;s pubspec.yaml file. To do this, simply add the following line to the dependencies section:</p><pre>dependencies:<br>  http: ^0.13.3</pre><p>This will ensure that the latest version of the http package is installed in your project.</p><h4>1. HTTP Request</h4><p>HTTP (Hypertext Transfer Protocol) is a protocol used for sending and receiving data over the internet. In this section we will cover constituent components to HTTP.</p><p><strong>Body Encoding<br></strong>Body encoding is a technique used to serialize or encode the data being sent in an HTTP request or response body in a format that can be transmitted over the network.</p><pre>enum BodyEncoding{<br>  url,<br>  json,<br>  body,<br>  xml<br>}</pre><p><strong>Content Type<br></strong>In HTTP networking, the Content-Type header is used to specify the format of the data being sent in a request or response. It informs the receiving party how to interpret the data and how to handle it.</p><pre>class ContentType extends Enum&lt;String&gt; {<br>  const ContentType(String val) : super(val);<br><br>  static const ContentType json = ContentType(&#39;application/json&#39;);<br>  static const ContentType body = ContentType(&#39;application/x-www-form-urlencoded; charset=utf-8&#39;);<br>  static const ContentType multipart = ContentType(&#39;multipart/form-data&#39;);<br>  static const ContentType xml = ContentType(&#39;application/xml&#39;);<br>}</pre><p><strong>Method<br></strong>Methods are used to indicate the desired action to be performed on a resource in an HTTP request.</p><pre>class HTTPMethod extends Enum&lt;String&gt; {<br>  const HTTPMethod(String val) : super(val);<br><br>  static const HTTPMethod get = HTTPMethod(&#39;GET&#39;);<br>  static const HTTPMethod post = HTTPMethod(&#39;POST&#39;);<br>  static const HTTPMethod put = HTTPMethod(&#39;PUT&#39;);<br>  static const HTTPMethod delete = HTTPMethod(&#39;DELETE&#39;);<br>  static const HTTPMethod patch = HTTPMethod(&#39;PATCH&#39;);<br>}</pre><p><strong>Request</strong></p><p>The Request class in the http package of Flutter represents an HTTP request that can be sent to a server. This class allows you to create custom HTTP requests by specifying the request method, URL, headers, and body.</p><pre>class HTTPRequest extends Request {<br><br>  final EndpointBuilder service;<br><br>  HTTPRequest(this.service)<br>      : super(<br>      service.httpMethod.value,<br>      Uri.parse(<br>          service.path));<br><br><br>  @override<br>  String get body {<br>    switch (service.bodyEncoding) {<br>      case BodyEncoding.json:<br>        return json.encode(service.parameters);<br>      case BodyEncoding.body:<br>        return service.parameters.toString();<br>      default:<br>        return &quot;&quot;;<br>    }<br>  }<br><br>  @override<br>  Map&lt;String, String&gt; get headers {<br>    var values = {&quot;content-type&quot;: service.contentType.value};<br>    values.addAll(service.headers);<br>    return values;<br>  }<br><br>  @override<br>  Uint8List get bodyBytes {<br>    if (service.parameters == null) {<br>      return Uint8List(0);<br>    }<br>    if (service.bodyEncoding == BodyEncoding.body) {<br>      final queryParameters = Uri(queryParameters: service.parameters);<br>      List&lt;int&gt; bodyBytes = utf8.encode(queryParameters.query);<br>      return Uint8List.fromList(bodyBytes);<br>    } else {<br>      final encodedBody = const Utf8Codec().encode(body);<br>      return Uint8List.fromList(encodedBody);<br>    }<br>  }<br><br>  @override<br>  Uri get url {<br>    if (service.bodyEncoding == BodyEncoding.url) {<br>      return Uri.parse(&#39;${service.path}${service.queryParameters}&#39;);<br>    }<br>    return Uri.parse(service.path);<br>  }<br><br>}</pre><h4>2. Network</h4><p>Networking generally refers to the process of sending and receiving data over the internet using the HTTP protocol. The <strong>Network Layer in Flutter</strong> app is responsible for handling these HTTP requests and responses. Here we will add environment and exception handler.</p><pre>enum NetworkEnvironment {<br>  production,<br>  qa<br>}</pre><pre>class NetworkException implements Exception {<br>  final _message;<br>  final _prefix;<br><br>  NetworkException([this._message, this._prefix]);<br><br>  @override<br>  String toString() {<br>    return &quot;$_prefix$_message&quot;;<br>  }<br>}<br><br>class FetchDataException extends NetworkException {<br>  FetchDataException([String? message])<br>      : super(message, &quot;Error During Communication: &quot;);<br>}<br><br>class BadRequestException extends NetworkException {<br>  BadRequestException([message]) : super(message, &quot;Invalid Request: &quot;);<br>}<br><br>class UnauthorisedException extends NetworkException {<br>  UnauthorisedException([message]) : super(message, &quot;Unauthorised Request: &quot;);<br>}</pre><h4>3. Endpoint</h4><p>Creating an endpoint in Flutter typically involves setting up a web server to handle incoming HTTP requests and return the appropriate responses.</p><pre>abstract class Endpoint {<br>  late String path;<br>  late HTTPMethod httpMethod;<br>  late ContentType contentType;<br>  late BodyEncoding bodyEncoding;<br>  late Map&lt;String, String&gt; headers;<br>  List&lt;MultipartFile&gt;? files;<br>  Map&lt;String, dynamic&gt;? parameters;<br>}</pre><pre><br>class EndpointBuilder implements Endpoint {<br><br>  @override<br>  late String path;<br><br>  @override<br>  late ContentType contentType;<br><br>  @override<br>  late BodyEncoding bodyEncoding;<br><br>  @override<br>  late HTTPMethod httpMethod;<br><br>  @override<br>  Map&lt;String, dynamic&gt;? parameters;<br><br>  @override<br>  List&lt;MultipartFile&gt;? files;<br><br>  @override<br>  late Map&lt;String, String&gt; headers = {<br>    &quot;Authorization&quot;: &quot;YOUR TOKEN&quot;<br>  };<br><br>  String get queryParameters {<br>    if (httpMethod == HTTPMethod.get &amp;&amp; parameters != null) {<br>      final jsonString = Uri(queryParameters: parameters);<br>      return &#39;?${jsonString.query}&#39;;<br>    }<br>    return &#39;&#39;;<br>  }<br>}</pre><h4>4. Request</h4><pre>abstract class RequestControllerImp {<br>  Future&lt;dynamic&gt; execute({required EndpointBuilder endpoint});<br>}<br><br>class RequestController implements RequestControllerImp {<br><br>  final _client = Client();<br><br>  @override<br>  Future execute({required EndpointBuilder endpoint}) async {<br><br>    BaseRequest request = HTTPRequest(endpoint);<br><br>    try {<br>      final response = await _client.send(request);<br>      if (response.statusCode &gt;= 200 &amp;&amp;<br>          response.statusCode &lt;= 299) {<br>        final data = await response.stream.transform(utf8.decoder).join();<br>        return jsonDecode(data.toString());<br>      } else {<br>        returnException(response);<br>      }<br>    } on SocketException {<br>      throw FetchDataException(&#39;No Internet Connection&#39;);<br>    }<br>  }<br><br>  dynamic returnException(StreamedResponse response) {<br>    switch (response.statusCode) {<br>      case 400:<br>        throw BadRequestException(response.toString());<br>      case 401:<br>      case 403:<br>      case 404:<br>        throw UnauthorisedException(response);<br>      case 500:<br>      default:<br>        throw FetchDataException(<br>            &#39;Error occurred while communication with server&#39; &#39; with status code : ${response.statusCode}&#39;);<br>    }<br>  }<br>}</pre><h4>5. API</h4><p>In this tutorial i’ve used this public api <a href="https://pokeapi.co/">https://pokeapi.co/</a> where you can find here.</p><pre><br>const environment = NetworkEnvironment.qa;<br><br>abstract class _PokeApiImp {<br>  String get baseUrl;<br><br>  EndpointBuilder pokeList(PokeListReq req);<br>}<br><br>class PokeApi implements _PokeApiImp {<br><br>  @override<br>  String get baseUrl {<br>    switch (environment) {<br>      case NetworkEnvironment.production:<br>        return &quot;https://pokeapi.co/api/v2&quot;;<br>      case NetworkEnvironment.qa:<br>        return &quot;https://pokeapi.co/api/v2&quot;;<br>    }<br>  }<br><br>  @override<br>  EndpointBuilder pokeList(PokeListReq req) {<br>    var request = EndpointBuilder();<br>    request.path = baseUrl+&quot;/pokemon&quot;;<br>    request.bodyEncoding = BodyEncoding.url;<br>    request.contentType = ContentType.body;<br>    request.httpMethod = HTTPMethod.get;<br>    request.parameters = req.toMap();<br>    return request;<br>  }<br>}</pre><p><strong>Data Models</strong></p><p><strong>Response &amp; Request</strong></p><pre>class PokeListRes {<br>  PokeListRes({<br>    this.results,<br>  });<br><br>  List&lt;Pokemon&gt;? results;<br><br>  factory PokeListRes.fromJson(Map&lt;String, dynamic&gt; json) =&gt; PokeListRes(<br>    results: json[&quot;results&quot;] == null ? null : List&lt;Pokemon&gt;.from(json[&quot;results&quot;].map((x) =&gt; Pokemon.fromJson(x))),<br>  );<br>}</pre><pre>class PokeListReq {<br><br>  PokeListReq({<br>    required this.limit<br>  });<br><br>  String limit;<br><br>  Map&lt;String, dynamic&gt; toMap() {<br>    var params = {<br>      &quot;limit&quot;: limit,<br>    };<br>    return params;<br>  }<br>}</pre><h4><strong>6. Repository</strong></h4><p>When it comes to APIs, a repository can be used to encapsulate the logic for making API requests and handling API responses. This can make it easier to maintain and test the application, as the details of the API implementation are hidden from the rest of the codebase. The repository provides a simple and consistent interface for working with the API, making it easier to add or modify API functionality as needed.</p><pre>abstract class RepositoryImp {<br>  Future&lt;PokeListRes?&gt; pokeList(PokeListReq req) async {<br>    return null;<br>  }<br>}<br><br>class Repository implements RepositoryImp {<br><br>  @override<br>  Future&lt;PokeListRes?&gt; pokeList(PokeListReq req) async {<br>    var router = RequestController();<br>    final serverResponse = await router.execute(endpoint: PokeApi().pokeList(req));<br>    final jsonData = PokeListRes.fromJson(serverResponse);<br>    return jsonData;<br>  }<br>}</pre><p>Finally we can call the poke list;</p><pre>  final _myRepo = Repository();<br><br>   _myRepo.pokeList(PokeListReq(limit: &quot;10&quot;))<br>        .then((value) =&gt; _setResponse(value))<br>        .onError((error, stackTrace) =&gt; _setError(error.toString()));<br><br>  void _setResponse(PokeListRes? response) {<br><br>  }<br><br>  void _setError(String msg) {<br><br>  }</pre><p>In next episodes i’ll try to add file upload via Multipart and some xml requests…</p><p>Here full of source;</p><p><a href="https://github.com/aliozkara/NetworkLayerFlutter">GitHub - aliozkara/NetworkLayerFlutter: Extendable network layer for Flutter and sample app with MVVM</a></p><p>If you know of any other useful tool Network Layer for Flutter, please share them in the comments.</p><p>If you enjoyed this, please <a href="https://aliozkara.medium.com/">follow me on Medium</a> and <a href="https://twitter.com/imaliozkara">Twitter</a>.</p><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcaf3d594c1e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>