Skip to content

Instantly share code, notes, and snippets.

View Jenovas's full-sized avatar

Rafael Skubisz Jenovas

View GitHub Profile
// Background Location Priming Screen
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
int backgroundCheck = ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_BACKGROUND_LOCATION);
if (backgroundCheck != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.ACCESS_BACKGROUND_LOCATION}, 1);
}
}
// On Foreground Location Priming Screen
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
int foregroundCheck = ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION);
if (foregroundCheck != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
}
}
@Jenovas
Jenovas / FeedDataSource.java
Created March 8, 2020 14:16
getFeed from network or DB
public Maybe<List<FeedItem>> getFeedItems() {
return Maybe
.concat(getFeedItemsNetwork(), getFeedItemsDB())
.firstElement()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Maybe<List<FeedItem>> getFeedItemsNetwork() {
// Retrofit mFeedAPI that does the getFeedItems() network call
@Jenovas
Jenovas / AppDelegate.m
Created February 22, 2019 15:25
Pulsate SDK React - AppDelegate.m
#import <PULPulsate/PULPulsate.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
PULAuthorizationData* authData = [[PULAuthorizationData alloc] initWithAppId:@"APP_ID" andAppKey:@"APP_KEY" validationError:nil];
PULPulsateManager* manager = [PULPulsateFactory getInstanceWithAuthorizationData:authData withLocationEnabled:YES withPushEnabled:YES withLaunchOptions:launchOptions withPulsateAppDelegate:YES andPulsateNotificationDelegate:YES error:nil];
[manager startPulsateSession:^(BOOL success, NSError * _Nullable error) {
}];
}
@Jenovas
Jenovas / Podfile
Last active February 22, 2019 15:42
Pulsate SDK React - Podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'PulsateImplementation' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for PulsateImplementation
pod 'React', :path => '../node_modules/react-native'
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
@Jenovas
Jenovas / package.json
Last active February 22, 2019 14:42
Pulsate SDK React - package.json
"dependencies": {
"react": "16.6.1",
"react-native": "0.57.5",
"react-native-pulsate-sdk-react": "^1.0.36"
},
"devDependencies": {
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.49.1",
"react-test-renderer": "16.6.1"
@Jenovas
Jenovas / gradle-wrapper.properties
Created February 22, 2019 12:32
Pulsate SDK React - gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
@Jenovas
Jenovas / build.gradle
Last active February 22, 2019 15:09
Pulsate SDK React - android/app/build.gradle
android {
defaultConfig {
multiDexEnabled = true
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
@Jenovas
Jenovas / build.gradle
Last active February 22, 2019 12:30
Pulsate SDK React - android/build.gradle
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 27
supportLibVersion = "27.1.1"
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
@Jenovas
Jenovas / MainApplication.java
Last active February 22, 2019 13:22
Pulsate SDK React - MainApplication.java
import android.content.Context;
import android.support.multidex.MultiDex;
import com.pulsatehq.external.pulsate.factory.PulsateFactory;
import com.pulsatehq.internal.Pulsate;
import com.pulsatehq.internal.util.AuthorizationData;
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(base);