Small micro-channel subscription program news, I stepped pits are here!

The old template messages will be fully under stand No. 2020 January 10, which is today, but looks can now use! ! ! I've been changing for the better, but still not on the line, ready to adhere to the last day!

0, subscribe to news

Subscribe to briefly explain the characteristics of the message:

  • Authorized users can send a subscription message, once authorized issued a message, long-term subscription message template authorized under a theoretically unlimited message
  • Compared with the old template message permission only seven days, long after the subscription message is authorized to send unlimited authority information, as long as it does not send the long term.

Other basic template message is no different with the old, in the process of developing the subscription message, recorded some common pit, feel with the look! (8 particularly important)

1, developers can not debug tool

I remember last October, just subscribe to news that would fully open, happily facing documentation development, result: instant cynicism, check the code several times, obviously not wrong, but the TA is being given! It is given! It is given!

Later tried it on a real machine can lift authorize pop, stroll under development community found that this is a common problem, it is estimated that did not get resolved.

But now tips have been very straightforward, and we do not back this pot, remember to debug on the real machine!

2, on a real machine still can not afford to tune

Later it, wrote an article about subscription news, there are some developers ask me. Code is right, not an error, but also debugging on the real machine, but can not lift authorize pop.

This time should go to the library to check the basic version of the applet, the subscription message is said to be the basis of the library 2.1.0 this particular test more than I did, anyway, try to move closer to the date.

If you want to also authorize multiple subscription messages, it should be to the underlying library 2.8.2 above, you can see the library when adjusted basis the number of affected users, looking to get their own.

Library adjusted basis applet in the applet background -> Set inside view, adjust :

3, after multiple calls fail

After successfully invoking authorization, happy, happy, apart from accidentally calling more than a few times, and then found no response after clicking?

In fact, this is a small problem, iOS seemingly did not come across, Andrews met many times, not a hundred percent can reproduce.

Call frequency may be a problem too dense API interface failure, the end of the micro-channel background process, re-open on Mo was a problem.

Do not have points, API is a living, let TA rest will be, what to call 100 times without stopping to let you choose, they might strike is! And develop and cherish! Love API, the call to start!

4, record number

After the current test results are one-time subscription message multiple times authorized to send more than one subscription message, you can send authorized several times, but developers need their own record number of subscriptions.

The number of records have a question, if you turned off in the settings to receive the subscription message, it will fail before all times, so pro-test, depending on where you need to do to optimize the business.

5, subscribe to news content

Subscribe to a one-time message, but it is also possible to send fail, this may be just about the content.

Subscribe to news content template parameters are very stringent, or more than one character does not match with the parameters specified value have led to transmission fails, remember the words of the judge. According to the template to fill in the background when filling out the corresponding parameters, ** thing3, name5 **, for example, we are back with numbers.

6, the template ID

Subscribe to news corresponding template ID only need to add different service categories subscription service template only when the applet sometimes to see categories and add in the background announcement template library.

Visiting the community when it was discovered that if you delete a service category, corresponding to the subscription template will be deleted, this self-experience -

7, after the refusal can not be adjusted from

After the hand, if you're like me a little disobedient, check the "Always keep the above options," then click Cancel, guess what happens? First try!

I found a very wonderful thing, whether I am to add a small program to remove, or re-authorize the landing, turn on or turn off the switch subscriptions are not authorized to lift the pop up.

This means that you completely TA and worship, if you want to see a different TA, only to re-add a same template, replace TEMPLATE_ID , this is your check has been rejected TEMPLATE_ID template you never see him again! In other words invoking page can not!

Check the "Always keep more than select" Click to allow the same never see TA ~

8, another call problem

前几天在把旧的模板消息改成订阅消息时,发现又无法调起了,手机调试,基础库没问题,弄了半天发现是表单的问题。

之前就的模板消息需要用到表单获取 formId,所以按钮绑定的就是 bindsubmit 事件,改成 bindtap 就没问题了,心中顿时一万匹澳洲羊驼呼啸而过~

尽量用 bindtap 调用订阅接口,官方说支付回调也可以,奈何个人开发者不能没得支付功能,至于那些 bindinput 之类的暂时就不做测试了!

这个问题可能遇到的人会比较多,因为很多开发者都是旧模板消息上直接改造,坑总是环环相扣!

9、订阅消息点击路径

订阅消息发送后,点击消息会跳转到我们指定的页面,如果没有指定的话,貌似是跳转至首页。

与旧模板消息不同的是,订阅消息的 path 路径跳的是线上版本,也就是开发版本无法测试到。

不过改写的话一般不会有问题,就是新开发时记得把路径配对。

10、判断是否授权

wx.requestSubscribeMessage 调用订阅消息时,success 回调只能判断是否成功调起授权窗口

如果想要判断用户是否授权,就需要用动态 TEMPLATE_ID 的去判断,accept 表示授权,reject 表示取消授权,ban 表示被后台封禁,我是这样写的:

if(res[TEMPLATE_ID] === 'reject')

if(res[TEMPLATE_ID] === 'accept')

11、最后

其实我觉得两者配合使用更好,但是人微言轻,只能想想,不过也支持微信的决定。

虽然订阅消息还有长期订阅模板,但是目前只对一些公共服务类目开放,作为个人开发者感受不到,也测试不了。据一些小道消息传闻说是 2 月份会开放一些其他服务类目,拭目以待。

之前写过一个 PHP 订阅消息的模板,API 模板关注同名公众号,后台回复「订阅消息」获取。

肯定还有一些没有遇到的坑点,下次凑齐几个再更新,如果大家有一些其他的坑点,可以写留言分享一下!

分享即学习,我是玖柒后,奥利给~

公众号「我是玖柒后」首发,分享即学习!

Guess you like

Origin www.cnblogs.com/msunh/p/12175555.html