Skip to content

Instantly share code, notes, and snippets.

View andresilveirah's full-sized avatar
💭
🤖

André Herculano andresilveirah

💭
🤖
View GitHub Profile
@andresilveirah
andresilveirah / WaitBeforeRelaunch.swift
Created November 3, 2022 16:53
I'm not sure the app's threads are suspended like `sleep`, but the code in this gist will pause for a bit before relaunching the app for UI testing.
func waitAndRelaunch(timeout: TimeInterval = 0) {
let waitingExpectation = XCTestExpectation(description: "Wait a bit")
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(Int(timeout))) {
waitingExpectation.fulfill()
}
self.wait(for: [waitingExpectation], timeout: timeout + 1)
self.app.relaunch()
}
import Foundation
import CoreData
class PersistentContainer: NSPersistentContainer {
static let modelName = "MyDataModel"
static var main: PersistentContainer? = {
guard
let modelURL = Bundle.framework.url(forResource: modelName, withExtension: "momd"),
let model = NSManagedObjectModel(contentsOf: modelURL)
else {
@andresilveirah
andresilveirah / SourcePoint_AndroidTV.md
Created August 26, 2020 10:28
Using SourcePoint's Android SDK with Android TV

Android TV

Our Android SDK can be used, without modifications, with Android TV.

Limitations

  1. Although a WebView is present, most of Android TV don't include an external browser. Opening links from within the consent message or PM, needs re-thinking. We currently open them in an external browser, this narrows the scope of the SDK and can concentrate on dealing with only SDK related resources in the WebView.

  2. Navigation needs to be 1st class citzen. On mobile, the user is free to tap anywhere in the screen and navigating between elements is effortless. On an OTT environment, the navigation is limited to a directional controller, making it difficult to navigate from one element to another when the order of the elements is not thought up-front.

@andresilveirah
andresilveirah / SourcePoint_AppleTV.md
Last active August 19, 2020 10:02
Using the SP SDK with Apple TV

Apple TV

There are 2 ways of developing apps for Apple TV. They are known as Native and TVML. Native is quite straight forward and works pretty much the same as an iOS app with all of its native components and lifecycle methods. TVML is a client-server based. Views are built using predefined templates by Apple or using the markup language provided (TVML).

Native

It's possible to reuse almost the entire SDK with a few remarks:

  1. There's no WebView. Therefore, we can only leverage the native message. Since we do not yet support a native PM, we're only able to support 1st layer messaging.
  2. The code will need a bit of a refactoring. Since a big chunk of the SDK relies on the existence of the WebKit module, we'll need to conditionally load code for different platforms (iOS or tvOS).

TVML

After applying the changes to make the SDK reusable on tvOS (described above) we are able to support TVML as well. With the same caveats as the native approach, no webview, no external browser.

Unified Wrapper

The majority of (if not all) our clients, when integrating with our SDKs, have pointed out the integration is really cumbersome when covering both GDPR and CCPA. We also pay a high price in terms of development to maintain two repositories in sync (x2 platforms, iOS and Android).

In oder to solve this problem we're merging the two SDKs into one meaning the SDKs will no longer "know" if they are dealing with CCPA or GDPR only. Instead, they will deal with all legislations at the same time.

POST message-url?inApp=true&native=true|false

Also known as "get", this endpoint will receive the account/property/campaign info as well as meta and uuid for all legislations (gdpr/ccpa).

Request

import React from 'react';
import './App.css';
const Winner = (props) => (
<div className="winner-section">
<img src="https://image.flaticon.com/icons/png/512/321/321773.png" width="50" height="50" />
Winner: {props.winnerName}
</div>
)

onReceiveMessageData(Object msgData):

when the scenario "decides" a message should show, msgData is:

{
  msgID: 50983,
  d: { abp: false, abt: false },
  o: { wl: false, oir: false },
  ci: { comp: false, src: 0 },
  u: { uuid: "3febf9dc-af84-42b8-ab23-9325bcf68ad7", bucket: 554 },
  info: {

Integrating SourcePoint's Swift SDK into an Obj-C Project

Impact in bundle size

In order to evaluate what's the impact in bundle size our SDK written in Swift has, we've created a Obj-C project from scratch, archived it for development and released on App Store (TestFlight). We later on added the ConsentViewController (our SDK) to the project and repeated the proccess. Some observations:

  • App Thinning was enabled and set to All compatible device variants in both releases.
  • Cocoapods was used to manage dependencies.
  • In the release that included our SDK, when archiving, the following option was enabled:
{
"pillows": {
"small": {
"name": "Nackenstützkissen G-COZY",
"height": "8 cm",
"picture": "http://betteninnovation.com/kissen-klein/"
},
"medium": {
"name": "Nackenstützkissen G-COZY",
"height": "10 cm",
@andresilveirah
andresilveirah / npm_colors.js
Created August 5, 2017 08:51
Colors on NPM console
// This might work only on MacOSX
// You can print colorful text to command when run nodejs application.
console.log('\x1b[36m%s\x1b[0m', info); //cyan
console.log('\x1b[33m%s\x1b[0m: ', path); //yellow
// Here is reference of colors and other characters:
Reset = "\x1b[0m"
Bright = "\x1b[1m"