Skip to content

Instantly share code, notes, and snippets.

View oded-regev's full-sized avatar

Oded Regev oded-regev

View GitHub Profile
@oded-regev
oded-regev / skAdNetworkSignature.java
Created November 2, 2020 13:12
Prepare the Signature for SkAdNetwork iOS14
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 November 2, 2020 13:10
iOS14 example on how to use loadProduct() with SKAdNetwork signature support
-(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 January 16, 2019 13:26
Example for audio recording
//
// 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 October 19, 2015 14:27
Android - Adding Advertiser ID param to all url in webview Raw
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 October 19, 2015 13:34
iOS - Adding Advertiser ID param to all url in webview
#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) {