「Apple が広告をブロック」したというが

img_2937

すべてのネット広告業者に神の裁きを、Apple様の広告ブロックです : 市況かぶ全力2階建

【検証】やっぱりアドブロックでGA無効化は本当だった件

これだけユーザの多いiOSに「広告ブロック機能をつけた」ということですが,

調査母数は少ないが、少なくともGoogle/GDNのadsenseが主な対象であることは、間違いなさそうである。

しかし、「アプリをダウンロードして、設定をしなければならない」ハードルがあり、疑問点として、「有料アプリを購入してまで、広告を非表示にするのか?」がある。

【検証】iOS9の広告ブロック機能は、運用系広告の脅威となるのか? - でぶててのWEB録

幸いにも「iOS 9」の広告をブロックする機能はデフォルトでSafariに実装されるということではなく、iOSデベロッパーが広告ブロック機能を実装できる機能を用意した、ということ。

パソコンの拡張機能と同様に、ユーザーはそのような機能を持つアプリをApp Storeからダウンロードし、広告をブロックできるという意味だ。

ウェブメディアに大打撃?!「iOS 9」、Safariで広告をブロックする機能を実装か?! | gori.me(ゴリミー)

正確にはiOS 9のSafariで「特定のコンテンツをブロックする拡張機能を開発できるようになった」ということのようでした。

iOS 9に「広告ブロック機能」ではなく「Safariの拡張機能としてコンテンツブロック機能を開発できるようになった」が正解 | 男子ハック

Safari 9.0 - Whats New Safari

ネットユーザー
  + iOS
    + ブラウザ
      + Safari ***
      + Chrome
    + アプリ
      + 専用ビューア
      + RSSビューア
  + Android
    + ブラウザ
      + Chrome
    + アプリ
      + 専用ビューア
      + RSSビューア
  + Windows
    ...

結局
「(有料)ブロックアプリで iOS の Safari 上で広告をブロックできる」
ということのみになる.

当然「広告ブロックをブロックする」コンテンツ配信者も登場してくる.

<p id="ads">
<script type="text/javascript"><!--
google_ad_client = "their-ad-code-here";
/* 160x600, droite */
google_ad_slot = "their-ad-code-here";
google_ad_width = 160;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

</p>

<script type="text/javascript"><!--
if(document.getElementsByTagName("iframe").item(0) == null)
{
    document.write("<div style='width:160px; height:600px; padding-top: 280px; margin-left:5px;border:1px solid #000000; text-align:center; font-family:century gothic, arial, helvetica, sans serif;padding-left:5px;padding-right:5px;'>Advertising seems to be blocked by your browser.<br /><br /><span style='font-size:10px'>Please notice that advertising helps us to host the project.<br /><br />If you find these ads intrusive or inappropriate, please contact me.</span><img src='http://www.playonlinux.com/images/abp.jpg' alt='Adblock Plus' /></div>");
}
--></script>

adsense - How to detect Adblock on my website? - Stack Overflow

This code is quite handy if you do not want to wrap your existing Adsense code with a CSS ID or class. it utilizes the fact that Google’s ad code creates an iframe with the id “iframe”. So as long as you don’t already have something on your page with that ID, this’d work for you too.

<script type="text/javascript"><!--
if(document.getElementsByTagName("iframe").item(0) == null)
{
    document.write("TEXT TO DISPLAY IF ADBLOCK IS ACTIVE");
}
--></script>

Ultimate Guide To Detecting AdBlock

WordPress であれば,

WordPress › Ad Blocking Detector « WordPress Plugins

OS上での制御となるので, iPhoneネイティブアプリ開発者向けにも
公開できるように思うが, まずは「限定Safariのみ」の様子見なのか.

当分は, 広告ブロックアプリ開発者だけの一人勝ち?

知らんけど.

コピペでブロックする 「iOS9 広告ブロック」

話題のコンテンツブロッカー「たった7つの正規表現」なのか?


Chrome CustomTabs 使い方 バックグランド処理で高速に

nexus2cee_stuff_thumb

[I/O 2015] Chrome Custom Tabs Will Add Easy And Rich Web Content To Any App With Chrome Capabilities

サービス経由で「ウォームアップ」,「URL先読み」を行って
高速に開く.

公開されている Googleサンプルのうち利用するヘルパークラスなどは
前回エントリを参照.

 

1. バインド

ウォームアップも同時に行う.
アクテビティのライフサイクルに合わせて.

public class SampleActivity extends AppCompatActivity
        implements CustomTabActivityHelper.ConnectionCallback {

    private CustomTabActivityHelper mCustomTabActivityHelper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mCustomTabActivityHelper = new CustomTabActivityHelper();
        mCustomTabActivityHelper.setConnectionCallback(this);

    }

    @Override
    protected void onStart() {
        super.onStart();
        mCustomTabActivityHelper.bindCustomTabsService(this);
    }

    @Override
    protected void onStop() {
        super.onStop();
        mCustomTabActivityHelper.unbindCustomTabsService(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mCustomTabActivityHelper.setConnectionCallback(null);
    }

    @Override
    public void onCustomTabsConnected() {
    }

    @Override
    public void onCustomTabsDisconnected() {
    }

}

 

2. プリフェッチ

開くであろうURLが確定した時点でバックグランドで先読み.

mCustomTabActivityHelper.mayLaunchUrl(uri, null, null);

 

3. 起動

前回とほぼ同じ.
タイトル, アニメーションを付けてなめらかな体感に.
R.anim.slide_* はサンプルのものを利用.

CustomTabsIntent customTabsIntent =
    new CustomTabsIntent.Builder(mCustomTabActivityHelper.getSession())
        .setShowTitle(true)
        .setStartAnimations(this, R.anim.slide_in_right, R.anim.slide_out_left)
        .setExitAnimations(this, android.R.anim.slide_in_left, android.R.anim.slide_out_right)
        .build();
CustomTabActivityHelper.openCustomTab(this, customTabsIntent, uri, new WebViewFallback());

 

以上をまとめてテンプレート的に

public class SampleActivity extends AppCompatActivity
        implements CustomTabActivityHelper.ConnectionCallback {

    private CustomTabActivityHelper mCustomTabActivityHelper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mCustomTabActivityHelper = new CustomTabActivityHelper();
        mCustomTabActivityHelper.setConnectionCallback(this);

    }

    private void preFetchUrl(Uri uri) {
        mCustomTabActivityHelper.mayLaunchUrl(uri, null, null);
    }

    private void open(Uri uri) {
         CustomTabsIntent customTabsIntent = 
            new CustomTabsIntent.Builder(mCustomTabActivityHelper.getSession())
            .setShowTitle(true)
            .setStartAnimations(this, R.anim.slide_in_right, R.anim.slide_out_left)
            .setExitAnimations(this, android.R.anim.slide_in_left, android.R.anim.slide_out_right)
            .build();
         CustomTabActivityHelper.openCustomTab(this, customTabsIntent, uri, new WebViewFallback());
    }

    @Override
    protected void onStart() {
        super.onStart();
        mCustomTabActivityHelper.bindCustomTabsService(this);
    }

    @Override
    protected void onStop() {
        super.onStop();
        mCustomTabActivityHelper.unbindCustomTabsService(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mCustomTabActivityHelper.setConnectionCallback(null);
    }

    @Override
    public void onCustomTabsConnected() {
    }

    @Override
    public void onCustomTabsDisconnected() {
    }

}

イベントからプリフェッチしてからのオープンすればよい.

しかし「先読みのタイミング」て…

(つづく)

Chrome Custom Tabs を とりあえず数行で使う


Chrome Custom Tabs を とりあえず数行で使う

スマホでブラウザを起動する, っての最近では面倒.

LINEとかメッセージでリンクを送ってくる人とか.

20150910-215123

さりげなく開かずにテキトーな会話を続けたりします.

考えてみると「なんかブラウザって重いしトロい」から.

そこで, 最近登場したのが「Chrome Custom Tabs」というしくみ.

Chrome Custom Tabs - Google Chrome

performance

表示までが非常に高速化されてるようにに見える.

実装しようとサンプルをダウンロードしてみる.

GoogleChrome/custom-tabs-client

アプリ内モジュールやヘルパーやプロセス間の通信など
依存関係があるのでわかりづらい.

とりあえずシンプルにURLを渡すだけでで起動してみたいだけなので以下で.

build.gradle

compile 'com.android.support:customtabs:23.0.1'

サンプル内モジュール customtabs 以下は不要.

コピペするクラス

CustomTabsHelper
KeepAliveService
CustomTabActivityHelper
WebViewFallback

shared というモジュールは作らずベタクラスとしてコピペ.
アプリ内モジュール依存はなしで.

起動

...
Uri uri = Uri.parse("http://google.com/");
CustomTabsIntent customTabsIntent =
    new CustomTabsIntent.Builder().build();
CustomTabActivityHelper
    .openCustomTab(this, customTabsIntent, uri, new WebViewFallback());
...

UIカスタマイズはしない. するならここで.

WebViewFallback#openUri()

    ...
    //Intent intent = new Intent(activity, WebViewActivity.class);
    //intent.putExtra(WebActivity.EXTRA_URL, uri.toString());
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(uri);
    activity.startActivity(intent);
    ...

Chromeアプリ (stable/beta/dev) をインストールしてない場合は,
デフォルトブラウザなどに暗黙的に投げる.

で ?

起動はできる.
が, これだけでは恩恵にありつけない.

20150910-224352

サイト内検索などはできるようにはなるが
「なんかブラウザって重いしトロい」が解消せず.

以下の機能があるという.

Pre-warming of the Browser in the background, while avoiding stealing resources from the application.

Providing a likely URL in advance to the browser, which may perform speculative work, speeding up page load time.

これを使わないと意味ないな...

(つづく)