Skip to content

Instantly share code, notes, and snippets.

Avatar

Oded Regev oded-regev

View GitHub Profile
@oded-regev
oded-regev / skAdNetworkSignature.java
Created Nov 2, 2020
Prepare the Signature for SkAdNetwork iOS14
View skAdNetworkSignature.java
package main.java.com.abccompany.example;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.security.*;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Base64;
import java.util.regex.Pattern;
@oded-regev
oded-regev / showAd.m
Created Nov 2, 2020
iOS14 example on how to use loadProduct() with SKAdNetwork signature support
View showAd.m
-(void) openAppInstallRec:(OBRecommendation * _Nonnull)rec inNavController:(UINavigationController * _Nonnull)navController {
if (@available(iOS 11.3, *)) {
SKStoreProductViewController *storeViewController = [[SKStoreProductViewController alloc] init];
NSDictionary *productParameters = [self prepareLoadProductParams:rec];
NSLog(@"loadProductWithParameters: %@", productParameters);
[storeViewController loadProductWithParameters:productParameters completionBlock:^(BOOL result, NSError * _Nullable error) {
// result - true if the product information was successfully loaded, otherwise false.
NSLog(@"loadProductWithParameters - result: %@, error: %@", result ? @"true" : @"false", [error localizedDescription]);
}];
@oded-regev
oded-regev / ViewController.m
Created Jan 16, 2019
Example for audio recording
View ViewController.m
//
// ViewController.m
// AudioRecordTest
//
// Created by -------- on 16/01/2019.
// Copyright © 2019 -----. All rights reserved.
//
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
@oded-regev
oded-regev / customWebview.java
Created Oct 19, 2015
Android - Adding Advertiser ID param to all url in webview Raw
View customWebview.java
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.contains("api_user_id")) {
return false;
}
url += (url.contains("?")) ? "&" : "?";
url += "api_user_id=";
url += "<AD_ID_FROM_SOMEWHERE_ELSE>";
@oded-regev
oded-regev / customWebview.m
Last active Oct 19, 2015
iOS - Adding Advertiser ID param to all url in webview
View customWebview.m
#pragma mark - WebView
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSString *url = request.URL.absoluteString;
NSString *advertiserId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
NSString *adIdParam = [NSString stringWithFormat:@"api_user_id=%@",advertiserId];
NSRange extraParam = [url rangeOfString:adIdParam];
if (extraParam.location == NSNotFound) {