Skip to content
lixu edited this page Jan 11, 2016 · 6 revisions

General

What's the difference between cordova-plugin-wechat and SocialSharing-PhoneGap-Plugin?

cordova-plugin-wechat uses the official wechat sdk, and SocialSharing-PhoneGap-Plugin does not. It uses the OS's default sharing feature (Intent on android, and UIActivityViewController on iOS) instead.

The benefit of using an official sdk is that we will have all the features provided by the official sdk, such as authentication, payment, analytics, and much more. Compared with using OS's default sharing feature, it loses the flexibility of sharing on other platforms, such as weibo, facebook, twitter, etc.

Installation/Uninstallation

TypeError: Cannot convert undefined or null to object

After installing the plugin, an error happened as follows:

Saving plugin to package.json file
Error happened [TypeError: Cannot convert undefined or null to object]
TypeError: Cannot convert undefined or null to object
    at Function.keys (native)
    at Object.getPluginFromFetchJsonByLocator (/usr/local/lib/node_modules/ionic/node_modules/ionic-app-lib/lib/state.js:734:26)
    ...

It was caused by package.json. You can find out which plugin is causing this issue by adding console.log(lookupPlugin); in the for loop in /usr/local/lib/node_modules/ionic/node_modules/ionic-app-lib/lib/state.js at line 730. Then, reinstall that plugin will solve the issue.

TypeError: Cannot read property 'buffer' of undefined

See CB7781.

Sharing

Is it required for my app to be approved by Wechat in order to test?

For android, yes. For iOS, no.

After sharing, it doesn't return back to my app.

(iOS)Please make sure the URL Type is correct. (Android) Your app signature is correct.

Payment

How could I generate all the parameters required in payment request?

Here is a php demo for that.

Debugging

Debugging in Android

You can replace the libammsdk.jar with libammsdk_debug.jar, and find the debugging messages in logcat. For example:

# assume you are at your project's root folder
cp plugins/xu.li.cordova.wechat/src/android/libammsdk_debug.jar platforms/android/libs/libammsdk.jar
adb logcat | grep 'MicroMsg.SDK'

Is there any debugging tool for payment API?

微信公众平台支付接口调试工具.

Publish

ld: bitcode bundle could not be generated (iOS)

Change Enable bitcode to No. See http://stackoverflow.com/questions/30848208/new-warnings-in-ios9.

Rejected by Apple app store claiming we should provide ways to allow people to authenticate/# with WeChat for people without installing the WeChat app.

You can hide the Wechat Login button if the wechat app is not installed.

$scope.showWechatLogin = false;
if (typeof Wechat !== 'undefined') {
    Wechat.isInstalled(function (installed) {
        if (installed) {
             // Only show wechat login button if the Wechat App was detected
            $scope.showWechatLogin = true;
        }
    }, function (reason) {
    });
}

(Thanks @winsonchan and @Jeff-Tian)