1. 程式人生 > >掌淘SMSSDK遇到的坑—AppKey不存在 狀態碼406

掌淘SMSSDK遇到的坑—AppKey不存在 狀態碼406

問題描述:呼叫sdk中

RegisterPage page = new RegisterPage();
//如果使用我們的ui,沒有申請模板編號的情況下需傳null
page.setTempCode(null);
page.setRegisterCallback(new EventHandler() {
   public void afterEvent(int event, int result, Object data) {
      
   }
});
page.show(this);

或者:

CountryPage countryPage = new CountryPage();
countryPage.setCountryId(currentId); countryPage.setCountryRuls(countryRules); Log.e("showCountrySelect","page = "); countryPage.showForResult(mRegisterActivity, null, new FakeActivity() { @Override public void onResult(HashMap<String, Object> arg0) { }

});

獲取國家列表介面報網路異常請稍後重試,抓包看到返回狀態碼406,appKey為null,找客服調了很久,最後換了個客服給的appKey就可以用了,然後切回我的key也可以用了,但是過不一會就又報這個錯。

解決方法:把

MobSDK {
    //    appKey "***"
    //    appSecret "*****"

    SMSSDK {
        gui true
    }
}

這個配置的appkey註釋掉換到manifest中:

<meta-data android:name="Mob-AppKey" android:value="*******"/>
<meta-data android:name="Mob-AppSecret" android:value="***************"/>

刪除程式碼:

countryPage.setCountryRuls(countryRules
);

程式碼不要混淆,或者按官方指導修改混淆檔案。

需要的許可權提前申請

這樣就沒問題了。