The old template will be removed on January 10, 2020, today, but it’s still available!! I have changed, just not online yet, ready to stick to the last day!
0. Subscribe to messages
A brief description of the features of subscription messages:
- If a user is authorized to send a subscription message, the message can be sent once. If a long-term subscription message template is authorized to send a message once, the message can be sent indefinitely
- Compared with the old template, the permission to send messages is reserved for seven days. After the subscription message is authorized, the permission to send messages is unlimited. It is valid for a long time if the message is not sent.
The rest is basically the same as the old template message, in the process of developing the subscription message, recorded some common potholes, feel together! (Point 8 is particularly important)
Developer tools cannot be debugged
I remember in October last year, subscription information was just fully open when I was cheerfully developing the document. The result was: instant doubt of life, I checked the code for several times, but TA was wrong! An error! An error!
Later, I tried to hang the authorization popover on the real machine, and found that this is a common problem in the development community. I guess there is no solution.
But now the hint has been very straightforward, we do not carry this pot, remember to debug on the real machine!
The real machine still can not adjust
Later, I wrote an article about subscription messaging, and some developers asked me. The code is correct, no errors reported, but also on the real machine debugging, but can not hang the authorization popover.
This time should go to check the basic version of the small program library, subscription message is said to be above the base library 2.1.0, this I did not have a specific test, anyway try to get closer to the latest.
If you want to authorize multiple subscription messages at the same time, it should be above the base library 2.8.2. When the base library adjusts, you can see how many users are affected.
Applet base library adjustment in the applet background -> Settings inside view, adjust:
3. Invalid after repeated calls
Can successfully call authorization, happy, happy accidentally called a few more times, and then found that there is no response after clicking?
This is actually a small problem, iOS seems not encountered, Android encountered many times, not 100% can be repeated.
If the call frequency is too dense, API interface failure may occur. End the wechat background process and open it again.
Don’t keep clicking, API is also alive, let TA rest, what 100 times non-stop call for you to choose, or not good strike! And develop and cherish! Take care of your API and start calling it!
4. Record times
The current test results show that multiple subscription messages can be sent after multiple authorization, and multiple subscription messages can be sent after several authorization, but the developer needs to record the number of subscriptions.
There is a problem with the number of times recorded. If the user turns off receiving subscription messages in the Settings, all previous times will be invalid. In this case, it needs to be optimized for the specific business.
5. Subscribe to message content
Subscribes to a one-time message, but may fail to deliver it, which may be content related.
Subscribe message template content parameters are very strict, one more character or different from the parameter value can cause send failure, remember to judge the number of words. Fill in the corresponding parameters according to the template in the background, such as thing3 and name5, which are followed by numbers.
6. Template ID
The template ID corresponding to the subscription message needs to be added in the background bulletin template library. Subscription templates for different service classes can only be seen and added when the applet service category is available.
If you delete a service category, the corresponding subscription template will also be deleted
7, refused to be able to adjust
Guess what happens if, like me, you’ve got a bit of a hand jerk and checked “Always keep above” and then hit Cancel? Try it first!
I found something amazing. No matter I deleted the applet and added it, re-authorized login, or turned off the subscription switch, the authorization popover couldn’t be hung.
If you want to see the same template again, you have to create a new TEMPLATE_ID. You will never see the TEMPLATE_ID template again. Page change also can’t tune up!
Check “Always keep the above options” and click “Allow”
8. Another invocation problem
A few days ago, WHEN I changed the old template message into subscription message, I found that it could not be adjusted again. During mobile phone debugging, there was no problem with the basic library. After a long time, I found that there was a problem with the form.
The template message needs to use the form to obtain the formId, so the button is bound to the BindSubmit event, change it to Bindtap, no problem, suddenly 10,000 Australian alpacas roar by ~
Use bindTap as far as possible to call the subscription interface, the official says that payment callback is also possible, but individual developers can not do without the payment function, as for those bindinput and so on will not test for now!
This problem may encounter people will be more, because many developers are the old template message directly transformed, pit is always linked!
9. Subscribe message click path
After the subscription message is sent, clicking the message will jump to the page we specified, if not specified, it seems to jump to the home page.
Unlike the old template message, the path of the subscription message jumps to the online version, which is not tested by the development version.
However, rewriting is generally not a problem, is new development remember to pair the path.
10. Determine whether to authorize
With wx. RequestSubscribeMessage call subscribe to news, success callback can only determine the success of the authorization window.
If you want to determine whether the user is authorized, you need to use dynamic TEMPLATE_ID. Accept indicates authorization, reject indicates rejection, and ban indicates blocking.
if(res[TEMPLATE_ID] === 'reject')
if(res[TEMPLATE_ID] === 'accept')
11, the last
In fact, I think it is better to use them together, but I can only think about it, but ALSO support wechat’s decision.
While subscription messaging also has a long-term subscription template, it is currently only available in some public service categories and cannot be felt or tested as an individual developer. There are rumors that some other service categories will open in February, but wait and see.
Before I wrote a PHP subscription message template, API template concerned with the same public number, background reply “subscription message” to obtain.
There must be some potholes we haven’t met yet, we will update them next time, if you have some other potholes, you can write a message to share!
Sharing is learning. I’m queen Ollie